Last active
January 7, 2020 15:39
-
-
Save mvsde/f74ad9f5e43994478060e5a559f21922 to your computer and use it in GitHub Desktop.
Hide element visually but keep it in accessibility tree
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
/** | |
* Visually hides elements but keeps them accessible for screen readers and | |
* keyboard users. | |
* | |
* Source: | |
* https://allyjs.io/tutorials/hiding-elements.html#2017-edition-of-visuallyhidden | |
*/ | |
.sr-only:not(:focus):not(:active) { | |
position: absolute; | |
width: 1px; | |
height: 1px; | |
margin: -1px; | |
border: 0; | |
padding: 0; | |
white-space: nowrap; | |
clip-path: inset(100%); | |
clip: rect(0 0 0 0); | |
overflow: hidden; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment