@untemps/svelte-use-tooltip
Version:
Svelte action to display a tooltip
76 lines (66 loc) • 1.15 kB
CSS
.__tooltip {
position: absolute;
z-index: 9999;
background-color: black;
color: white;
text-align: center;
border-radius: 6px;
padding: 0.5rem;
}
.__tooltip::after {
content: '';
position: absolute;
margin-left: -5px;
border-width: 5px;
border-style: solid;
}
.__tooltip-area {
position: absolute;
left: 0.5rem;
background: transparent;
width: 100%;
height: 100%;
margin: -0.5rem;
}
.__tooltip-top::after {
bottom: -10px;
left: 50%;
border-color: black transparent transparent transparent;
}
.__tooltip-bottom::after {
top: -10px;
left: 50%;
border-color: transparent transparent black transparent;
}
.__tooltip-left::after {
top: calc(50% - 5px);
right: -10px;
border-color: transparent transparent transparent black;
}
.__tooltip-right::after {
top: calc(50% - 5px);
left: -5px;
border-color: transparent black transparent transparent;
}
.__tooltip-enter {
animation: fadeIn 0.2s linear forwards;
}
.__tooltip-leave {
animation: fadeOut 0.2s linear forwards;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}