Last active
October 22, 2016 14:44
-
-
Save vikrantnegi/e4f11e9b132d0cf0dd3af89a60ae9166 to your computer and use it in GitHub Desktop.
Visually hide some text while keeping it accessible
This file contains hidden or 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
/* For only text */ | |
.sr-only { | |
border: 0 !important; | |
clip: rect(1px, 1px, 1px, 1px) !important; | |
-webkit-clip-path: inset(50%) !important; | |
clip-path: inset(50%) !important; | |
height: 1px !important; | |
overflow: hidden !important; | |
padding: 0 !important; | |
position: absolute !important; | |
width: 1px !important; | |
white-space: nowrap !important; | |
} | |
/* For focussable elemnts eg. skip links */ | |
.sr-only-focusable:focus, | |
.sr-only-focusable:active { | |
clip: auto !important; | |
-webkit-clip-path: none !important; | |
clip-path: none !important; | |
height: auto !important; | |
overflow: visible !important; | |
width: auto !important; | |
white-space: normal !important; | |
} | |
/* | |
Credit: http://hugogiraudel.com/2016/10/13/css-hide-and-seek/ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment