0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00
Bootstrap/scss/_tooltip.scss

138 lines
4.5 KiB
SCSS
Raw Normal View History

2014-12-02 23:02:35 +01:00
// Base class
.tooltip {
2021-07-29 08:21:53 +02:00
// scss-docs-start tooltip-css-vars
--#{$variable-prefix}tooltip-zindex: #{$zindex-tooltip};
--#{$variable-prefix}tooltip-max-width: #{$tooltip-max-width};
--#{$variable-prefix}tooltip-padding-x: #{$tooltip-padding-x};
--#{$variable-prefix}tooltip-padding-y: #{$tooltip-padding-y};
--#{$variable-prefix}tooltip-margin: #{$tooltip-margin};
--#{$variable-prefix}tooltip-font-size: #{$tooltip-font-size};
--#{$variable-prefix}tooltip-color: #{$tooltip-color};
--#{$variable-prefix}tooltip-bg: #{$tooltip-bg};
--#{$variable-prefix}tooltip-border-radius: #{$tooltip-border-radius};
--#{$variable-prefix}tooltip-opacity: #{$tooltip-opacity};
--#{$variable-prefix}tooltip-arrow-width: #{$tooltip-arrow-width};
--#{$variable-prefix}tooltip-arrow-height: #{$tooltip-arrow-height};
$tooltip-arrow-color: null;
2014-12-02 23:02:35 +01:00
position: absolute;
2021-07-29 08:21:53 +02:00
z-index: var(--#{$variable-prefix}tooltip-zindex);
2014-12-02 23:02:35 +01:00
display: block;
2021-07-29 08:21:53 +02:00
margin: var(--#{$variable-prefix}tooltip-margin);
2015-06-19 08:56:43 +02: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.
@include reset-text();
2021-07-29 08:21:53 +02:00
@include font-size(var(--#{$variable-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 23:02:35 +01:00
opacity: 0;
2021-07-29 08:21:53 +02:00
&.show { opacity: var(--#{$variable-prefix}tooltip-opacity); }
2014-12-20 03:35:10 +01:00
2019-02-11 11:27:14 +01:00
.tooltip-arrow {
2017-05-23 14:17:07 +02:00
position: absolute;
display: block;
2021-07-29 08:21:53 +02:00
width: var(--#{$variable-prefix}tooltip-arrow-width);
height: var(--#{$variable-prefix}tooltip-arrow-height);
2017-05-23 14:17:07 +02:00
&::before {
position: absolute;
content: "";
border-color: transparent;
border-style: solid;
}
}
}
.bs-tooltip-top {
2021-07-29 08:21:53 +02:00
padding: var(--#{$variable-prefix}tooltip-arrow-height) 0;
2019-02-11 11:27:14 +01:00
.tooltip-arrow {
bottom: 0;
&::before {
2020-06-19 10:17:01 +02:00
top: -1px;
2021-07-29 08:21:53 +02:00
border-width: var(--#{$variable-prefix}tooltip-arrow-height) calc(var(--#{$variable-prefix}tooltip-arrow-width) * .5) 0; // stylelint-disable-line function-disallowed-list
border-top-color: var(--#{$variable-prefix}tooltip-bg);
}
}
}
2022-02-28 17:04:29 +01:00
/* rtl:begin:ignore */
.bs-tooltip-end {
2021-07-29 08:21:53 +02:00
padding: 0 var(--#{$variable-prefix}tooltip-arrow-height);
2019-02-11 11:27:14 +01:00
.tooltip-arrow {
2020-12-04 16:55:50 +01:00
left: 0;
2021-07-29 08:21:53 +02:00
width: var(--#{$variable-prefix}tooltip-arrow-height);
height: var(--#{$variable-prefix}tooltip-arrow-width);
&::before {
2020-12-04 16:55:50 +01:00
right: -1px;
2021-07-29 08:21:53 +02:00
border-width: calc(var(--#{$variable-prefix}tooltip-arrow-width) * .5) var(--#{$variable-prefix}tooltip-arrow-height) calc(var(--#{$variable-prefix}tooltip-arrow-width) * .5) 0; // stylelint-disable-line function-disallowed-list
border-right-color: var(--#{$variable-prefix}tooltip-bg);
}
}
}
2022-02-28 17:04:29 +01:00
/* rtl:end:ignore */
.bs-tooltip-bottom {
2021-07-29 08:21:53 +02:00
padding: var(--#{$variable-prefix}tooltip-arrow-height) 0;
2019-02-11 11:27:14 +01:00
.tooltip-arrow {
top: 0;
&::before {
2020-06-19 10:17:01 +02:00
bottom: -1px;
2021-07-29 08:21:53 +02:00
border-width: 0 calc(var(--#{$variable-prefix}tooltip-arrow-width) * .5) var(--#{$variable-prefix}tooltip-arrow-height); // stylelint-disable-line function-disallowed-list
border-bottom-color: var(--#{$variable-prefix}tooltip-bg);
}
}
}
2022-02-28 17:04:29 +01:00
/* rtl:begin:ignore */
.bs-tooltip-start {
2021-07-29 08:21:53 +02:00
padding: 0 var(--#{$variable-prefix}tooltip-arrow-height);
2019-02-11 11:27:14 +01:00
.tooltip-arrow {
2020-12-04 16:55:50 +01:00
right: 0;
2021-07-29 08:21:53 +02:00
width: var(--#{$variable-prefix}tooltip-arrow-height);
height: var(--#{$variable-prefix}tooltip-arrow-width);
&::before {
2020-12-04 16:55:50 +01:00
left: -1px;
2021-07-29 08:21:53 +02:00
border-width: calc(var(--#{$variable-prefix}tooltip-arrow-width) * .5) 0 calc(var(--#{$variable-prefix}tooltip-arrow-width) * .5) var(--#{$variable-prefix}tooltip-arrow-height); // stylelint-disable-line function-disallowed-list
border-left-color: var(--#{$variable-prefix}tooltip-bg);
}
}
}
2022-02-28 17:04:29 +01:00
/* rtl:end:ignore */
.bs-tooltip-auto {
2020-06-19 10:17:01 +02:00
&[data-popper-placement^="top"] {
@extend .bs-tooltip-top;
}
2020-06-19 10:17:01 +02:00
&[data-popper-placement^="right"] {
@extend .bs-tooltip-end;
}
2020-06-19 10:17:01 +02:00
&[data-popper-placement^="bottom"] {
@extend .bs-tooltip-bottom;
}
2020-06-19 10:17:01 +02:00
&[data-popper-placement^="left"] {
@extend .bs-tooltip-start;
2017-05-24 13:48:32 +02:00
}
2014-12-02 23:02:35 +01:00
}
// Wrapper for the tooltip content
.tooltip-inner {
2021-07-29 08:21:53 +02:00
max-width: var(--#{$variable-prefix}tooltip-max-width);
padding: var(--#{$variable-prefix}tooltip-padding-y) var(--#{$variable-prefix}tooltip-padding-x);
color: var(--#{$variable-prefix}tooltip-color);
2014-12-02 23:02:35 +01:00
text-align: center;
2021-07-29 08:21:53 +02:00
background-color: var(--#{$variable-prefix}tooltip-bg);
border-radius: var(--#{$variable-prefix}tooltip-border-radius, 0); // stylelint-disable-line property-disallowed-list
2014-12-02 23:02:35 +01:00
}