_popover.less 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. #reset-text();
  11. #font-size(@popover-font-size);
  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. #border-radius(@popover-border-radius);
  18. #box-shadow(@popover-box-shadow);
  19. .arrow {
  20. position: absolute;
  21. display: block;
  22. width: @popover-arrow-width;
  23. height: @popover-arrow-height;
  24. margin: 0 @popover-border-radius;
  25. &::before,
  26. &::after {
  27. position: absolute;
  28. display: block;
  29. content: "";
  30. border-color: transparent;
  31. border-style: solid;
  32. }
  33. }
  34. }
  35. .bs-popover-top {
  36. margin-bottom: @popover-arrow-height;
  37. > .arrow {
  38. //bottom: calc((@popover-arrow-height + @popover-border-width) * -1);
  39. bottom: subtract(-@popover-arrow-height, @popover-border-width);
  40. &::before {
  41. bottom: 0;
  42. border-width: @popover-arrow-height (@popover-arrow-width / 2) 0;
  43. border-top-color: @popover-arrow-outer-color;
  44. }
  45. &::after {
  46. bottom: @popover-border-width;
  47. border-width: @popover-arrow-height (@popover-arrow-width / 2) 0;
  48. border-top-color: @popover-arrow-color;
  49. }
  50. }
  51. }
  52. .bs-popover-right {
  53. margin-left: @popover-arrow-height;
  54. > .arrow {
  55. //left: calc((@popover-arrow-height + @popover-border-width) * -1);
  56. left: subtract(-@popover-arrow-height, @popover-border-width);
  57. width: @popover-arrow-height;
  58. height: @popover-arrow-width;
  59. margin: @popover-border-radius 0; // make sure the arrow does not touch the popover's rounded corners
  60. &::before {
  61. left: 0;
  62. border-width: (@popover-arrow-width / 2) @popover-arrow-height (@popover-arrow-width / 2) 0;
  63. border-right-color: @popover-arrow-outer-color;
  64. }
  65. &::after {
  66. left: @popover-border-width;
  67. border-width: (@popover-arrow-width / 2) @popover-arrow-height (@popover-arrow-width / 2) 0;
  68. border-right-color: @popover-arrow-color;
  69. }
  70. }
  71. }
  72. .bs-popover-bottom {
  73. margin-top: @popover-arrow-height;
  74. > .arrow {
  75. //top: calc((@popover-arrow-height + @popover-border-width) * -1);
  76. top: subtract(-@popover-arrow-height, @popover-border-width);
  77. &::before {
  78. top: 0;
  79. border-width: 0 (@popover-arrow-width / 2) @popover-arrow-height (@popover-arrow-width / 2);
  80. border-bottom-color: @popover-arrow-outer-color;
  81. }
  82. &::after {
  83. top: @popover-border-width;
  84. border-width: 0 (@popover-arrow-width / 2) @popover-arrow-height (@popover-arrow-width / 2);
  85. border-bottom-color: @popover-arrow-color;
  86. }
  87. }
  88. // This will remove the popover-header's border just below the arrow
  89. .popover-header::before {
  90. position: absolute;
  91. top: 0;
  92. left: 50%;
  93. display: block;
  94. width: @popover-arrow-width;
  95. margin-left: (-@popover-arrow-width / 2);
  96. content: "";
  97. border-bottom: @popover-border-width solid @popover-header-bg;
  98. }
  99. }
  100. .bs-popover-left {
  101. margin-right: @popover-arrow-height;
  102. > .arrow {
  103. //right: calc((@popover-arrow-height + @popover-border-width) * -1);
  104. right: subtract(-@popover-arrow-height, @popover-border-width);
  105. width: @popover-arrow-height;
  106. height: @popover-arrow-width;
  107. margin: @popover-border-radius 0; // make sure the arrow does not touch the popover's rounded corners
  108. &::before {
  109. right: 0;
  110. border-width: (@popover-arrow-width / 2) 0 (@popover-arrow-width / 2) @popover-arrow-height;
  111. border-left-color: @popover-arrow-outer-color;
  112. }
  113. &::after {
  114. right: @popover-border-width;
  115. border-width: (@popover-arrow-width / 2) 0 (@popover-arrow-width / 2) @popover-arrow-height;
  116. border-left-color: @popover-arrow-color;
  117. }
  118. }
  119. }
  120. .bs-popover-auto {
  121. &[x-placement^="top"] {
  122. &:extend(.bs-popover-top all);
  123. }
  124. &[x-placement^="right"] {
  125. &:extend(.bs-popover-right all);
  126. }
  127. &[x-placement^="bottom"] {
  128. &:extend(.bs-popover-bottom all);
  129. }
  130. &[x-placement^="left"] {
  131. &:extend(.bs-popover-left all);
  132. }
  133. }
  134. // Offset the popover to account for the popover arrow
  135. .popover-header {
  136. padding: @popover-header-padding-y @popover-header-padding-x;
  137. margin-bottom: 0; // Reset the default from Reboot
  138. #font-size(@font-size-base);
  139. // LESS PORT: Less doesn’t strip “empty” property values so we have to check for a value first.
  140. & when not (@popover-header-color = ~"") { color: @popover-header-color; }
  141. background-color: @popover-header-bg;
  142. border-bottom: @popover-border-width solid darken(@popover-header-bg, 5%);
  143. #border-top-radius(@popover-inner-border-radius);
  144. &:empty {
  145. display: none;
  146. }
  147. }
  148. .popover-body {
  149. padding: @popover-body-padding-y @popover-body-padding-x;
  150. color: @popover-body-color;
  151. }