1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-23 00:39:54 +00:00

Convert popover's arrows to generated CSS content via :before/:after

This commit is contained in:
Bernardo Gurgel Filho 2015-08-23 17:54:38 -03:00
parent 2ae5fdf9dd
commit 8ef66df6d7
2 changed files with 75 additions and 53 deletions

View File

@ -28,7 +28,6 @@ const Popover = (($) => {
trigger : 'click', trigger : 'click',
content : '', content : '',
template : '<div class="popover" role="tooltip">' template : '<div class="popover" role="tooltip">'
+ '<div class="popover-arrow"></div>'
+ '<h3 class="popover-title"></h3>' + '<h3 class="popover-title"></h3>'
+ '<div class="popover-content"></div></div>' + '<div class="popover-content"></div></div>'
}) })
@ -44,8 +43,7 @@ const Popover = (($) => {
const Selector = { const Selector = {
TITLE : '.popover-title', TITLE : '.popover-title',
CONTENT : '.popover-content', CONTENT : '.popover-content'
ARROW : '.popover-arrow'
} }
const Event = { const Event = {

View File

@ -23,19 +23,22 @@
&.bs-tether-element-attached-bottom { &.bs-tether-element-attached-bottom {
margin-top: -$popover-arrow-width; margin-top: -$popover-arrow-width;
.popover-arrow { &::before,
bottom: -$popover-arrow-outer-width; &::after {
left: 50%; left: 50%;
border-bottom-width: 0;
}
&::before {
bottom: -$popover-arrow-outer-width;
margin-left: -$popover-arrow-outer-width; margin-left: -$popover-arrow-outer-width;
border-top-color: $popover-arrow-outer-color; border-top-color: $popover-arrow-outer-color;
border-bottom-width: 0; }
&::after {
bottom: 1px; &::after {
margin-left: -$popover-arrow-width; bottom: -($popover-arrow-outer-width - 1);
content: ""; margin-left: -$popover-arrow-width;
border-top-color: $popover-arrow-color; border-top-color: $popover-arrow-color;
border-bottom-width: 0;
}
} }
} }
@ -43,19 +46,22 @@
&.bs-tether-element-attached-left { &.bs-tether-element-attached-left {
margin-left: $popover-arrow-width; margin-left: $popover-arrow-width;
.popover-arrow { &::before,
&::after {
top: 50%; top: 50%;
border-left-width: 0;
}
&::before {
left: -$popover-arrow-outer-width; left: -$popover-arrow-outer-width;
margin-top: -$popover-arrow-outer-width; margin-top: -$popover-arrow-outer-width;
border-right-color: $popover-arrow-outer-color; border-right-color: $popover-arrow-outer-color;
border-left-width: 0; }
&::after {
bottom: -$popover-arrow-width; &::after {
left: 1px; left: -($popover-arrow-outer-width - 1);
content: ""; margin-top: -($popover-arrow-outer-width - 1);
border-right-color: $popover-arrow-color; border-right-color: $popover-arrow-color;
border-left-width: 0;
}
} }
} }
@ -63,19 +69,34 @@
&.bs-tether-element-attached-top { &.bs-tether-element-attached-top {
margin-top: $popover-arrow-width; margin-top: $popover-arrow-width;
.popover-arrow { &::before,
top: -$popover-arrow-outer-width; &::after {
left: 50%; left: 50%;
margin-left: -$popover-arrow-outer-width;
border-top-width: 0; border-top-width: 0;
}
&::before {
top: -$popover-arrow-outer-width;
margin-left: -$popover-arrow-outer-width;
border-bottom-color: $popover-arrow-outer-color; border-bottom-color: $popover-arrow-outer-color;
&::after { }
top: 1px;
margin-left: -$popover-arrow-width; &::after {
content: ""; top: -($popover-arrow-outer-width - 1);
border-top-width: 0; margin-left: -$popover-arrow-width;
border-bottom-color: $popover-arrow-color; border-bottom-color: $popover-title-bg;
} }
// This will remove the popover-title's border just below the arrow
.popover-title::before {
position: absolute;
top: 0;
left: 50%;
display: block;
width: 20px;
margin-left: -10px;
content: "";
border-bottom: 1px solid $popover-title-bg;
} }
} }
@ -83,19 +104,22 @@
&.bs-tether-element-attached-right { &.bs-tether-element-attached-right {
margin-left: -$popover-arrow-width; margin-left: -$popover-arrow-width;
.popover-arrow { &::before,
&::after {
top: 50%; top: 50%;
border-right-width: 0;
}
&::before {
right: -$popover-arrow-outer-width; right: -$popover-arrow-outer-width;
margin-top: -$popover-arrow-outer-width; margin-top: -$popover-arrow-outer-width;
border-right-width: 0;
border-left-color: $popover-arrow-outer-color; border-left-color: $popover-arrow-outer-color;
&::after { }
right: 1px;
bottom: -$popover-arrow-width; &::after {
content: ""; right: -($popover-arrow-outer-width - 1);
border-right-width: 0; margin-top: -($popover-arrow-outer-width - 1);
border-left-color: $popover-arrow-color; border-left-color: $popover-arrow-color;
}
} }
} }
} }
@ -120,21 +144,21 @@
// //
// .popover-arrow is outer, .popover-arrow::after is inner // .popover-arrow is outer, .popover-arrow::after is inner
.popover-arrow { .popover::before,
&, .popover::after {
&::after { position: absolute;
position: absolute; display: block;
display: block; width: 0;
width: 0; height: 0;
height: 0; border-color: transparent;
border-color: transparent; border-style: solid;
border-style: solid;
}
} }
.popover-arrow {
.popover::before {
content: "";
border-width: $popover-arrow-outer-width; border-width: $popover-arrow-outer-width;
} }
.popover-arrow::after { .popover::after {
content: ""; content: "";
border-width: $popover-arrow-width; border-width: $popover-arrow-width;
} }