_popover.scss 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. .popover {
  2. position: absolute;
  3. top: 0;
  4. /*rtl:ignore*/
  5. left: 0;
  6. z-index: $zindex-popover;
  7. display: block;
  8. max-width: $popover-max-width;
  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: $popover-font-size;
  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($popover-border-radius);
  19. @include box-shadow($popover-box-shadow);
  20. .arrow {
  21. position: absolute;
  22. display: block;
  23. width: $popover-arrow-width;
  24. height: $popover-arrow-height;
  25. margin: 0 $border-radius-lg;
  26. &::before,
  27. &::after {
  28. position: absolute;
  29. display: block;
  30. content: "";
  31. border-color: transparent;
  32. border-style: solid;
  33. }
  34. }
  35. }
  36. .bs-popover-top {
  37. margin-bottom: $popover-arrow-height;
  38. .arrow {
  39. bottom: calc((#{$popover-arrow-height} + #{$popover-border-width}) * -1);
  40. }
  41. .arrow::before,
  42. .arrow::after {
  43. border-width: $popover-arrow-height ($popover-arrow-width / 2) 0;
  44. }
  45. .arrow::before {
  46. bottom: 0;
  47. border-top-color: $popover-arrow-outer-color;
  48. }
  49. .arrow::after {
  50. bottom: $popover-border-width;
  51. border-top-color: $popover-arrow-color;
  52. }
  53. }
  54. .bs-popover-right {
  55. /*rtl:ignore*/
  56. margin-left: $popover-arrow-height;
  57. .arrow {
  58. /*rtl:ignore*/
  59. left: calc((#{$popover-arrow-height} + #{$popover-border-width}) * -1);
  60. width: $popover-arrow-height;
  61. height: $popover-arrow-width;
  62. margin: $border-radius-lg 0; // make sure the arrow does not touch the popover's rounded corners
  63. }
  64. .arrow::before,
  65. .arrow::after {
  66. /*rtl:ignore*/
  67. border-width: ($popover-arrow-width / 2) $popover-arrow-height ($popover-arrow-width / 2) 0;
  68. }
  69. .arrow::before {
  70. /*rtl:begin:ignore*/
  71. left: 0;
  72. border-right-color: $popover-arrow-outer-color;
  73. /*rtl:end:ignore*/
  74. }
  75. .arrow::after {
  76. /*rtl:begin:ignore*/
  77. left: $popover-border-width;
  78. border-right-color: $popover-arrow-color;
  79. /*rtl:end:ignore*/
  80. }
  81. }
  82. .bs-popover-bottom {
  83. margin-top: $popover-arrow-height;
  84. .arrow {
  85. top: calc((#{$popover-arrow-height} + #{$popover-border-width}) * -1);
  86. }
  87. .arrow::before,
  88. .arrow::after {
  89. border-width: 0 ($popover-arrow-width / 2) $popover-arrow-height ($popover-arrow-width / 2);
  90. }
  91. .arrow::before {
  92. top: 0;
  93. border-bottom-color: $popover-arrow-outer-color;
  94. }
  95. .arrow::after {
  96. top: $popover-border-width;
  97. border-bottom-color: $popover-arrow-color;
  98. }
  99. // This will remove the popover-header's border just below the arrow
  100. .popover-header::before {
  101. position: absolute;
  102. top: 0;
  103. left: 50%;
  104. display: block;
  105. width: $popover-arrow-width;
  106. margin-left: ($popover-arrow-width / -2);
  107. content: "";
  108. border-bottom: $popover-border-width solid $popover-header-bg;
  109. }
  110. }
  111. .bs-popover-left {
  112. /*rtl:ignore*/
  113. margin-right: $popover-arrow-height;
  114. .arrow {
  115. /*rtl:ignore*/
  116. right: calc((#{$popover-arrow-height} + #{$popover-border-width}) * -1);
  117. width: $popover-arrow-height;
  118. height: $popover-arrow-width;
  119. margin: $border-radius-lg 0; // make sure the arrow does not touch the popover's rounded corners
  120. }
  121. .arrow::before,
  122. .arrow::after {
  123. /*rtl:ignore*/
  124. border-width: ($popover-arrow-width / 2) 0 ($popover-arrow-width / 2) $popover-arrow-height;
  125. }
  126. .arrow::before {
  127. /*rtl:begin:ignore*/
  128. right: 0;
  129. border-left-color: $popover-arrow-outer-color;
  130. /*rtl:end:ignore*/
  131. }
  132. .arrow::after {
  133. /*rtl:begin:ignore*/
  134. right: $popover-border-width;
  135. border-left-color: $popover-arrow-color;
  136. /*rtl:end:ignore*/
  137. }
  138. }
  139. .bs-popover-auto {
  140. &[x-placement^="top"] {
  141. @extend .bs-popover-top;
  142. }
  143. &[x-placement^="right"] {
  144. @extend .bs-popover-right;
  145. }
  146. &[x-placement^="bottom"] {
  147. @extend .bs-popover-bottom;
  148. }
  149. &[x-placement^="left"] {
  150. @extend .bs-popover-left;
  151. }
  152. }
  153. // Offset the popover to account for the popover arrow
  154. .popover-header {
  155. padding: $popover-header-padding-y $popover-header-padding-x;
  156. margin-bottom: 0; // Reset the default from Reboot
  157. font-size: $font-size-base;
  158. color: $popover-header-color;
  159. background-color: $popover-header-bg;
  160. border-bottom: $popover-border-width solid darken($popover-header-bg, 5%);
  161. $offset-border-width: calc(#{$border-radius-lg} - #{$popover-border-width});
  162. @include border-top-radius($offset-border-width);
  163. &:empty {
  164. display: none;
  165. }
  166. }
  167. .popover-body {
  168. padding: $popover-body-padding-y $popover-body-padding-x;
  169. color: $popover-body-color;
  170. }