1
0
Fork 0
forked from Simnation/Main
Main/resources/[carscripts]/lc_utils/nui/css/tooltip.css
2025-06-07 08:51:21 +02:00

140 lines
No EOL
4.3 KiB
CSS

:root {
--tooltip-background-color: rgba(44, 44, 44, 0.9);
--tooltip-gradient-color-1: rgba(75, 75, 75, 0.44);
--tooltip-gradient-color-2: rgba(73, 73, 73, 0.44);
--tooltip-gradient-color-3: rgba(83, 83, 83, 0.44);
--tooltip-box-shadow-color: rgba(0, 0, 0, 0.2);
--tooltip-text-color: #fff;
--tooltip-arrow-color: rgba(58, 58, 58, 0.9);
}
/* Usage: <div data-tooltip-location="left" data-tooltip="Tooltip text"></div> */
[data-tooltip] {
position: relative;
z-index: 10;
}
/* Positioning and visibility settings of the tooltip */
[data-tooltip]:before, [data-tooltip]:after {
position: absolute;
visibility: hidden;
opacity: 0;
left: 50%;
bottom: calc(100% + 5px);
/* 5px is the size of the arrow */
pointer-events: none;
transition: 0.2s;
will-change: transform;
font-family: 'Montserrat', 'Arial' !important;
letter-spacing: normal;
}
/* The actual tooltip with a dynamic width */
[data-tooltip]:before {
content: attr(data-tooltip);
padding: 10px 18px;
min-width: 50px;
max-width: 300px;
width: max-content;
width: -moz-max-content;
border-radius: 6px;
font-size: 14px;
font-weight: 500;
background-color: var(--tooltip-background-color);
background-image: linear-gradient(30deg, var(--tooltip-gradient-color-1), var(--tooltip-gradient-color-2), var(--tooltip-gradient-color-3));
box-shadow: 0px 0px 24px var(--tooltip-box-shadow-color);
color: var(--tooltip-text-color);
text-align: center;
white-space: pre-wrap;
transform: translate(-50%, -5px) scale(0.5);
}
/* Tooltip arrow */
[data-tooltip]:after {
content: '';
border-style: solid;
border-width: 5px 5px 0px 5px;
/* CSS triangle */
border-color: var(--tooltip-arrow-color) transparent transparent transparent;
transition-duration: 0s;
/* If the mouse leaves the element, the transition effects for the tooltip arrow are "turned off" */
transform-origin: top;
/* Orientation setting for the slide-down effect */
transform: translateX(-50%) scaleY(0);
}
/* Tooltip becomes visible at hover */
[data-tooltip]:hover:before, [data-tooltip]:hover:after {
visibility: visible;
opacity: 1;
}
/* Scales from 0.5 to 1 -> grow effect */
[data-tooltip]:hover:before {
transform: translate(-50%, -5px) scale(1);
}
/* Arrow slide down effect only on mouseenter (NOT on mouseleave) */
[data-tooltip]:hover:after {
transition-delay: 0.1s;
/* Starting after the grow effect */
transition-duration: 0.2s;
transform: translateX(-50%) scaleY(1);
}
/* That's it. */
/* LEFT */
/* Tooltip + arrow */
[data-tooltip-location="left"]:before, [data-tooltip-location="left"]:after {
left: auto;
right: calc(100% + 5px);
bottom: 50%;
}
/* Tooltip */
[data-tooltip-location="left"]:before {
transform: translate(-5px, 50%) scale(0.5);
}
[data-tooltip-location="left"]:hover:before {
transform: translate(-5px, 50%) scale(1);
}
/* Arrow */
[data-tooltip-location="left"]:after {
border-width: 5px 0px 5px 5px;
border-color: transparent transparent transparent var(--tooltip-arrow-color);
transform-origin: left;
transform: translateY(50%) scaleX(0);
}
[data-tooltip-location="left"]:hover:after {
transform: translateY(50%) scaleX(1);
}
/* RIGHT */
[data-tooltip-location="right"]:before, [data-tooltip-location="right"]:after {
left: calc(100% + 5px);
bottom: 50%;
}
[data-tooltip-location="right"]:before {
transform: translate(5px, 50%) scale(0.5);
}
[data-tooltip-location="right"]:hover:before {
transform: translate(5px, 50%) scale(1);
}
[data-tooltip-location="right"]:after {
border-width: 5px 5px 5px 0px;
border-color: transparent var(--tooltip-arrow-color) transparent transparent;
transform-origin: right;
transform: translateY(50%) scaleX(0);
}
[data-tooltip-location="right"]:hover:after {
transform: translateY(50%) scaleX(1);
}
/* BOTTOM */
[data-tooltip-location="bottom"]:before, [data-tooltip-location="bottom"]:after {
top: calc(100% + 5px);
bottom: auto;
}
[data-tooltip-location="bottom"]:before {
transform: translate(-50%, 5px) scale(0.5);
}
[data-tooltip-location="bottom"]:hover:before {
transform: translate(-50%, 5px) scale(1);
}
[data-tooltip-location="bottom"]:after {
border-width: 0px 5px 5px 5px;
border-color: transparent transparent var(--tooltip-arrow-color) transparent;
transform-origin: bottom;
}