You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_tooltip.scss 4.2KB

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