_tooltip.scss 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // Base class
  2. .tooltip {
  3. position: absolute;
  4. z-index: $zindex-tooltip;
  5. display: block;
  6. margin: $tooltip-margin;
  7. // Our parent element can be arbitrary since tooltips are by default inserted as a sibling of their target element.
  8. // So reset our font and text properties to avoid inheriting weird values.
  9. @include reset-text();
  10. font-size: $tooltip-font-size;
  11. // Allow breaking very long words so they don't overflow the tooltip's bounds
  12. word-wrap: break-word;
  13. opacity: 0;
  14. &.show { opacity: $tooltip-opacity; }
  15. .arrow {
  16. position: absolute;
  17. display: block;
  18. width: $tooltip-arrow-width;
  19. height: $tooltip-arrow-height;
  20. &::before {
  21. position: absolute;
  22. content: "";
  23. border-color: transparent;
  24. border-style: solid;
  25. }
  26. }
  27. }
  28. .bs-tooltip-top {
  29. padding: $tooltip-arrow-height 0;
  30. .arrow {
  31. bottom: 0;
  32. &::before {
  33. top: 0;
  34. border-width: $tooltip-arrow-height ($tooltip-arrow-width / 2) 0;
  35. border-top-color: $tooltip-arrow-color;
  36. }
  37. }
  38. }
  39. .bs-tooltip-right {
  40. padding: 0 $tooltip-arrow-height;
  41. .arrow {
  42. /*rtl:ignore*/
  43. left: 0;
  44. width: $tooltip-arrow-height;
  45. height: $tooltip-arrow-width;
  46. &::before {
  47. /*rtl:begin:ignore*/
  48. right: 0;
  49. border-width: ($tooltip-arrow-width / 2) $tooltip-arrow-height ($tooltip-arrow-width / 2) 0;
  50. border-right-color: $tooltip-arrow-color;
  51. /*rtl:end:ignore*/
  52. }
  53. }
  54. }
  55. .bs-tooltip-bottom {
  56. padding: $tooltip-arrow-height 0;
  57. .arrow {
  58. top: 0;
  59. &::before {
  60. bottom: 0;
  61. border-width: 0 ($tooltip-arrow-width / 2) $tooltip-arrow-height;
  62. border-bottom-color: $tooltip-arrow-color;
  63. }
  64. }
  65. }
  66. .bs-tooltip-left {
  67. padding: 0 $tooltip-arrow-height;
  68. .arrow {
  69. /*rtl:ignore*/
  70. right: 0;
  71. width: $tooltip-arrow-height;
  72. height: $tooltip-arrow-width;
  73. &::before {
  74. /*rtl:begin:ignore*/
  75. left: 0;
  76. border-width: ($tooltip-arrow-width / 2) 0 ($tooltip-arrow-width / 2) $tooltip-arrow-height;
  77. border-left-color: $tooltip-arrow-color;
  78. /*rtl:end:ignore*/
  79. }
  80. }
  81. }
  82. .bs-tooltip-auto {
  83. &[x-placement^="top"] {
  84. @extend .bs-tooltip-top;
  85. }
  86. &[x-placement^="right"] {
  87. @extend .bs-tooltip-right;
  88. }
  89. &[x-placement^="bottom"] {
  90. @extend .bs-tooltip-bottom;
  91. }
  92. &[x-placement^="left"] {
  93. @extend .bs-tooltip-left;
  94. }
  95. }
  96. // Wrapper for the tooltip content
  97. .tooltip-inner {
  98. max-width: $tooltip-max-width;
  99. padding: $tooltip-padding-y $tooltip-padding-x;
  100. color: $tooltip-color;
  101. text-align: center;
  102. background-color: $tooltip-bg;
  103. @include border-radius($tooltip-border-radius);
  104. }