Created
December 6, 2024 12:32
-
-
Save wlkns/214652331d88315c07358bef6f6a2c09 to your computer and use it in GitHub Desktop.
Basic Tooltip Tailwind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[data-tooltip] { | |
@apply relative; | |
&:before, | |
&:after { | |
@apply absolute opacity-0; | |
@apply opacity-0 transition-opacity duration-500; | |
content: ''; | |
left: 50%; | |
} | |
&:before { | |
@apply text-center whitespace-nowrap text-xs; | |
@apply bg-black/75 text-white px-2 py-1 text-sm z-10; | |
@apply rounded-lg; | |
content: attr(data-tooltip); | |
transform: translateX(-50%) translateY(calc(-100% - 3px)); | |
} | |
&:after { | |
transform: translateX(-50%) translateY(-3px); | |
@apply border-5 border-transparent border-t-black/75; | |
} | |
&:hover:after, | |
&:hover:before { | |
@apply opacity-100; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment