_popover.scss 4.4KB

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