Skip to content

Instantly share code, notes, and snippets.

@Camwyn
Last active November 16, 2016 18:49
Show Gist options
  • Save Camwyn/72fe4963a9ad71f849f39ee2e3cb1c06 to your computer and use it in GitHub Desktop.
Save Camwyn/72fe4963a9ad71f849f39ee2e3cb1c06 to your computer and use it in GitHub Desktop.
Visually-hidden mixin. Uses selector-nest to allow showing on focus/active. Generated by SassMeister.com.
.example:not(:focus):not(:active) {
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
.example2 {
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
// ----
// libsass (v3.3.6)
// ----
@mixin visually-hidden( $focus: false ) {
@at-root #{if($focus, selector-nest('&:not(:focus):not(:active)'), '&')} {
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
}
@mixin screen-reader-text( $focus: false ) {
@include visually-hidden( $focus );
}
.example {
@include screen-reader-text(true);
}
.example2 {
@include screen-reader-text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment