0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-23 20:54:22 +01:00
Bootstrap/scss/_tooltip.scss

126 lines
4.9 KiB
SCSS
Raw Normal View History

2024-07-29 22:04:11 -07:00
@use "mixins/border-radius";
@use "mixins/deprecate";
@use "mixins/reset-text";
@use "variables";
@use "vendor/rfs";
2014-12-02 14:02:35 -08:00
// Base class
.tooltip {
2021-07-29 09:21:53 +03:00
// scss-docs-start tooltip-css-vars
2024-07-29 22:04:11 -07:00
--#{variables.$prefix}tooltip-zindex: #{variables.$zindex-tooltip};
--#{variables.$prefix}tooltip-max-width: #{variables.$tooltip-max-width};
--#{variables.$prefix}tooltip-padding-x: #{variables.$tooltip-padding-x};
--#{variables.$prefix}tooltip-padding-y: #{variables.$tooltip-padding-y};
--#{variables.$prefix}tooltip-margin: #{variables.$tooltip-margin};
@include rfs.rfs(variables.$tooltip-font-size, --#{variables.$prefix}tooltip-font-size);
--#{variables.$prefix}tooltip-color: #{variables.$tooltip-color};
--#{variables.$prefix}tooltip-bg: #{variables.$tooltip-bg};
--#{variables.$prefix}tooltip-border-radius: #{variables.$tooltip-border-radius};
--#{variables.$prefix}tooltip-opacity: #{variables.$tooltip-opacity};
--#{variables.$prefix}tooltip-arrow-width: #{variables.$tooltip-arrow-width};
--#{variables.$prefix}tooltip-arrow-height: #{variables.$tooltip-arrow-height};
2021-09-08 11:01:35 -07:00
// scss-docs-end tooltip-css-vars
2021-07-29 09:21:53 +03:00
2024-07-29 22:04:11 -07:00
z-index: var(--#{variables.$prefix}tooltip-zindex);
2014-12-02 14:02:35 -08:00
display: block;
2024-07-29 22:04:11 -07:00
margin: var(--#{variables.$prefix}tooltip-margin);
@include deprecate.deprecate("`$tooltip-margin`", "v5", "v5.x", true);
2015-06-18 23:56:43 -07:00
// Our parent element can be arbitrary since tooltips are by default inserted as a sibling of their target element.
// So reset our font and text properties to avoid inheriting weird values.
2024-07-29 22:04:11 -07:00
@include reset-text.reset-text();
@include rfs.font-size(var(--#{variables.$prefix}tooltip-font-size));
// Allow breaking very long words so they don't overflow the tooltip's bounds
word-wrap: break-word;
2014-12-02 14:02:35 -08:00
opacity: 0;
2024-07-29 22:04:11 -07:00
&.show { opacity: var(--#{variables.$prefix}tooltip-opacity); }
2014-12-19 18:35:10 -08:00
2019-02-11 11:27:14 +01:00
.tooltip-arrow {
2017-05-23 14:17:07 +02:00
display: block;
2024-07-29 22:04:11 -07:00
width: var(--#{variables.$prefix}tooltip-arrow-width);
height: var(--#{variables.$prefix}tooltip-arrow-height);
2017-05-23 14:17:07 +02:00
&::before {
position: absolute;
content: "";
border-color: transparent;
border-style: solid;
}
}
}
2022-05-04 15:31:57 +02:00
.bs-tooltip-top .tooltip-arrow {
2024-07-29 22:04:11 -07:00
bottom: calc(-1 * var(--#{variables.$prefix}tooltip-arrow-height)); // stylelint-disable-line function-disallowed-list
2022-05-04 15:31:57 +02:00
&::before {
top: -1px;
2024-07-29 22:04:11 -07:00
border-width: var(--#{variables.$prefix}tooltip-arrow-height) calc(var(--#{variables.$prefix}tooltip-arrow-width) * .5) 0; // stylelint-disable-line function-disallowed-list
border-top-color: var(--#{variables.$prefix}tooltip-bg);
}
}
2022-02-28 17:04:29 +01:00
/* rtl:begin:ignore */
2022-05-04 15:31:57 +02:00
.bs-tooltip-end .tooltip-arrow {
2024-07-29 22:04:11 -07:00
left: calc(-1 * var(--#{variables.$prefix}tooltip-arrow-height)); // stylelint-disable-line function-disallowed-list
width: var(--#{variables.$prefix}tooltip-arrow-height);
height: var(--#{variables.$prefix}tooltip-arrow-width);
2022-05-04 15:31:57 +02:00
&::before {
right: -1px;
2024-07-29 22:04:11 -07:00
border-width: calc(var(--#{variables.$prefix}tooltip-arrow-width) * .5) var(--#{variables.$prefix}tooltip-arrow-height) calc(var(--#{variables.$prefix}tooltip-arrow-width) * .5) 0; // stylelint-disable-line function-disallowed-list
border-right-color: var(--#{variables.$prefix}tooltip-bg);
}
}
2022-02-28 17:04:29 +01:00
/* rtl:end:ignore */
2022-05-04 15:31:57 +02:00
.bs-tooltip-bottom .tooltip-arrow {
2024-07-29 22:04:11 -07:00
top: calc(-1 * var(--#{variables.$prefix}tooltip-arrow-height)); // stylelint-disable-line function-disallowed-list
2022-05-04 15:31:57 +02:00
&::before {
bottom: -1px;
2024-07-29 22:04:11 -07:00
border-width: 0 calc(var(--#{variables.$prefix}tooltip-arrow-width) * .5) var(--#{variables.$prefix}tooltip-arrow-height); // stylelint-disable-line function-disallowed-list
border-bottom-color: var(--#{variables.$prefix}tooltip-bg);
}
}
2022-02-28 17:04:29 +01:00
/* rtl:begin:ignore */
2022-05-04 15:31:57 +02:00
.bs-tooltip-start .tooltip-arrow {
2024-07-29 22:04:11 -07:00
right: calc(-1 * var(--#{variables.$prefix}tooltip-arrow-height)); // stylelint-disable-line function-disallowed-list
width: var(--#{variables.$prefix}tooltip-arrow-height);
height: var(--#{variables.$prefix}tooltip-arrow-width);
2022-05-04 15:31:57 +02:00
&::before {
left: -1px;
2024-07-29 22:04:11 -07:00
border-width: calc(var(--#{variables.$prefix}tooltip-arrow-width) * .5) 0 calc(var(--#{variables.$prefix}tooltip-arrow-width) * .5) var(--#{variables.$prefix}tooltip-arrow-height); // stylelint-disable-line function-disallowed-list
border-left-color: var(--#{variables.$prefix}tooltip-bg);
}
}
2022-02-28 17:04:29 +01:00
/* rtl:end:ignore */
.bs-tooltip-auto {
2020-06-19 11:17:01 +03:00
&[data-popper-placement^="top"] {
@extend .bs-tooltip-top;
}
2020-06-19 11:17:01 +03:00
&[data-popper-placement^="right"] {
@extend .bs-tooltip-end;
}
2020-06-19 11:17:01 +03:00
&[data-popper-placement^="bottom"] {
@extend .bs-tooltip-bottom;
}
2020-06-19 11:17:01 +03:00
&[data-popper-placement^="left"] {
@extend .bs-tooltip-start;
2017-05-24 13:48:32 +02:00
}
2014-12-02 14:02:35 -08:00
}
// Wrapper for the tooltip content
.tooltip-inner {
2024-07-29 22:04:11 -07:00
max-width: var(--#{variables.$prefix}tooltip-max-width);
padding: var(--#{variables.$prefix}tooltip-padding-y) var(--#{variables.$prefix}tooltip-padding-x);
color: var(--#{variables.$prefix}tooltip-color);
2014-12-02 14:02:35 -08:00
text-align: center;
2024-07-29 22:04:11 -07:00
background-color: var(--#{variables.$prefix}tooltip-bg);
@include border-radius.border-radius(var(--#{variables.$prefix}tooltip-border-radius));
2014-12-02 14:02:35 -08:00
}