_popover.scss 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. .popover {
  2. position: absolute;
  3. top: 0;
  4. left: 0;
  5. z-index: $zindex-popover;
  6. display: block;
  7. max-width: $popover-max-width;
  8. padding: $popover-inner-padding;
  9. // Our parent element can be arbitrary since tooltips are by default inserted as a sibling of their target element.
  10. // So reset our font and text properties to avoid inheriting weird values.
  11. @include reset-text();
  12. font-size: $font-size-sm;
  13. // Allow breaking very long words so they don't overflow the popover's bounds
  14. word-wrap: break-word;
  15. background-color: $popover-bg;
  16. background-clip: padding-box;
  17. border: $popover-border-width solid $popover-border-color;
  18. @include border-radius($border-radius-lg);
  19. @include box-shadow($popover-box-shadow);
  20. // Popover directions
  21. &.popover-top,
  22. &.bs-tether-element-attached-bottom {
  23. margin-top: -$popover-arrow-width;
  24. &::before,
  25. &::after {
  26. left: 50%;
  27. border-bottom-width: 0;
  28. }
  29. &::before {
  30. bottom: -$popover-arrow-outer-width;
  31. margin-left: -$popover-arrow-outer-width;
  32. border-top-color: $popover-arrow-outer-color;
  33. }
  34. &::after {
  35. bottom: -($popover-arrow-outer-width - 1);
  36. margin-left: -$popover-arrow-width;
  37. border-top-color: $popover-arrow-color;
  38. }
  39. }
  40. &.popover-right,
  41. &.bs-tether-element-attached-left {
  42. margin-left: $popover-arrow-width;
  43. &::before,
  44. &::after {
  45. top: 50%;
  46. border-left-width: 0;
  47. }
  48. &::before {
  49. left: -$popover-arrow-outer-width;
  50. margin-top: -$popover-arrow-outer-width;
  51. border-right-color: $popover-arrow-outer-color;
  52. }
  53. &::after {
  54. left: -($popover-arrow-outer-width - 1);
  55. margin-top: -($popover-arrow-outer-width - 1);
  56. border-right-color: $popover-arrow-color;
  57. }
  58. }
  59. &.popover-bottom,
  60. &.bs-tether-element-attached-top {
  61. margin-top: $popover-arrow-width;
  62. &::before,
  63. &::after {
  64. left: 50%;
  65. border-top-width: 0;
  66. }
  67. &::before {
  68. top: -$popover-arrow-outer-width;
  69. margin-left: -$popover-arrow-outer-width;
  70. border-bottom-color: $popover-arrow-outer-color;
  71. }
  72. &::after {
  73. top: -($popover-arrow-outer-width - 1);
  74. margin-left: -$popover-arrow-width;
  75. border-bottom-color: $popover-title-bg;
  76. }
  77. // This will remove the popover-title's border just below the arrow
  78. .popover-title::before {
  79. position: absolute;
  80. top: 0;
  81. left: 50%;
  82. display: block;
  83. width: 20px;
  84. margin-left: -10px;
  85. content: "";
  86. border-bottom: 1px solid $popover-title-bg;
  87. }
  88. }
  89. &.popover-left,
  90. &.bs-tether-element-attached-right {
  91. margin-left: -$popover-arrow-width;
  92. &::before,
  93. &::after {
  94. top: 50%;
  95. border-right-width: 0;
  96. }
  97. &::before {
  98. right: -$popover-arrow-outer-width;
  99. margin-top: -$popover-arrow-outer-width;
  100. border-left-color: $popover-arrow-outer-color;
  101. }
  102. &::after {
  103. right: -($popover-arrow-outer-width - 1);
  104. margin-top: -($popover-arrow-outer-width - 1);
  105. border-left-color: $popover-arrow-color;
  106. }
  107. }
  108. }
  109. // Offset the popover to account for the popover arrow
  110. .popover-title {
  111. padding: $popover-title-padding-y $popover-title-padding-x;
  112. margin: 0; // reset heading margin
  113. font-size: $font-size-base;
  114. background-color: $popover-title-bg;
  115. border-bottom: $popover-border-width solid darken($popover-title-bg, 5%);
  116. $offset-border-width: ($border-width / $font-size-root);
  117. @include border-radius(($border-radius-lg - $offset-border-width) ($border-radius-lg - $offset-border-width) 0 0);
  118. &:empty {
  119. display: none;
  120. }
  121. }
  122. .popover-content {
  123. padding: $popover-content-padding-y $popover-content-padding-x;
  124. }
  125. // Arrows
  126. //
  127. // .popover-arrow is outer, .popover-arrow::after is inner
  128. .popover::before,
  129. .popover::after {
  130. position: absolute;
  131. display: block;
  132. width: 0;
  133. height: 0;
  134. border-color: transparent;
  135. border-style: solid;
  136. }
  137. .popover::before {
  138. content: "";
  139. border-width: $popover-arrow-outer-width;
  140. }
  141. .popover::after {
  142. content: "";
  143. border-width: $popover-arrow-width;
  144. }