_tooltip.scss 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. @include 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 {
  15. opacity: $tooltip-opacity;
  16. }
  17. .arrow {
  18. position: absolute;
  19. display: block;
  20. width: $tooltip-arrow-width;
  21. height: $tooltip-arrow-height;
  22. &::before {
  23. position: absolute;
  24. content: '';
  25. border-color: transparent;
  26. border-style: solid;
  27. }
  28. }
  29. }
  30. .bs-tooltip-top {
  31. padding: $tooltip-arrow-height 0;
  32. .arrow {
  33. bottom: 0;
  34. &::before {
  35. top: 0;
  36. border-width: $tooltip-arrow-height ($tooltip-arrow-width / 2) 0;
  37. border-top-color: $tooltip-arrow-color;
  38. }
  39. }
  40. }
  41. .bs-tooltip-right {
  42. padding: 0 $tooltip-arrow-height;
  43. .arrow {
  44. left: 0;
  45. width: $tooltip-arrow-height;
  46. height: $tooltip-arrow-width;
  47. &::before {
  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. }
  52. }
  53. }
  54. .bs-tooltip-bottom {
  55. padding: $tooltip-arrow-height 0;
  56. .arrow {
  57. top: 0;
  58. &::before {
  59. bottom: 0;
  60. border-width: 0 ($tooltip-arrow-width / 2) $tooltip-arrow-height;
  61. border-bottom-color: $tooltip-arrow-color;
  62. }
  63. }
  64. }
  65. .bs-tooltip-left {
  66. padding: 0 $tooltip-arrow-height;
  67. .arrow {
  68. right: 0;
  69. width: $tooltip-arrow-height;
  70. height: $tooltip-arrow-width;
  71. &::before {
  72. left: 0;
  73. border-width: ($tooltip-arrow-width / 2) 0 ($tooltip-arrow-width / 2) $tooltip-arrow-height;
  74. border-left-color: $tooltip-arrow-color;
  75. }
  76. }
  77. }
  78. .bs-tooltip-auto {
  79. &[x-placement^='top'] {
  80. @extend .bs-tooltip-top;
  81. }
  82. &[x-placement^='right'] {
  83. @extend .bs-tooltip-right;
  84. }
  85. &[x-placement^='bottom'] {
  86. @extend .bs-tooltip-bottom;
  87. }
  88. &[x-placement^='left'] {
  89. @extend .bs-tooltip-left;
  90. }
  91. }
  92. // Wrapper for the tooltip content
  93. .tooltip-inner {
  94. max-width: $tooltip-max-width;
  95. padding: $tooltip-padding-y $tooltip-padding-x;
  96. color: $tooltip-color;
  97. text-align: center;
  98. background-color: $tooltip-bg;
  99. @include border-radius($tooltip-border-radius);
  100. }