-
-
Save EtienneLem/4032653 to your computer and use it in GitHub Desktop.
Sass media queries and @extend
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
// Fairly safe way to visually hide content, but make it accessible to screen readers | |
.visually-hidden { | |
position: absolute; | |
left: -9999px; | |
height: 1px; | |
} | |
@media screen and (max-width: 700px) { | |
// Again, accessible to screen readers | |
// Example: <a href="/login" class="icon icon-twitter"><span class="mobile-offscreen">Single-click </span> log in with Twitter</a> | |
.mobile-offscreen { | |
@extend .visually-hidden; | |
} | |
} | |
// Extends actually add your `.mobile-offscreen` class to `.visually-hidden` like this: | |
/* | |
.visually-hidden, .visually-hidden { | |
position: absolute; | |
left: -9999px; | |
height: 1px; | |
} | |
*/ | |
// Leaving "nothing" in your media query. | |
// What you need is a mixin that duplicates `.visually-hidden` content into your media query | |
// It is not quite a Sass/SCSS bug. Stylus’ (and most likely Less (not tested)) extend works the same way. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment