-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tooltip to any UI element (#506)
- Loading branch information
1 parent
1b57136
commit 112371e
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
[data-tooltip] { | ||
position: relative; | ||
} | ||
|
||
[data-tooltip]::before, | ||
[data-tooltip]::after { | ||
font-size: 0.9rem; | ||
position: absolute; | ||
display: none; | ||
opacity: 0; | ||
} | ||
|
||
[data-tooltip]::before { | ||
content: ""; | ||
border: 0.5rem solid transparent; | ||
z-index: 1001; | ||
} | ||
|
||
[data-tooltip]::after { | ||
content: attr(data-tooltip); | ||
text-align: center; | ||
padding: 0.25rem 0.5rem; | ||
overflow: hidden; | ||
border-radius: 0.3rem; | ||
box-shadow: 0 1em 2em -0.5em rgba(0, 0, 0, 0.35); | ||
background: #000000; | ||
color: #ffffff; | ||
z-index: 1000; | ||
} | ||
|
||
[data-tooltip]:hover::before, | ||
[data-tooltip]:hover::after { | ||
display: block; | ||
opacity: 1; | ||
} | ||
[tooltip=""]::before, | ||
[tooltip=""]::after { | ||
display: none; | ||
} | ||
|
||
[data-tooltip]::before { | ||
bottom: 100%; | ||
border-bottom-width: 0; | ||
border-top-color: #000000; | ||
} | ||
|
||
[data-tooltip]::after { | ||
bottom: calc(100% + 0.5rem - 1px); | ||
} | ||
|
||
[data-tooltip]::before, | ||
[data-tooltip]::after { | ||
left: 50%; | ||
transform: translate(-50%, -0.5em); | ||
} | ||
|
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