Skip to content

Instantly share code, notes, and snippets.

@ryanburnette
Created November 2, 2012 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburnette/4004048 to your computer and use it in GitHub Desktop.
Save ryanburnette/4004048 to your computer and use it in GitHub Desktop.
CSS Helpers
// Helpers, adapted from HTML5 boilerplate
// Image replacement
@mixin ir {
background-color: transparent;
border: 0;
overflow: hidden;
/* IE 6/7 fallback */
*text-indent: -9999px;
&:before {
content: "";
display: block;
width: 0;
height: 100%;
}
}
// Hidden
%hidden {
display: none !important;
visibility: hidden;
}
// Visually hidden
@mixin visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
%visuallyhidden:active,
%visuallyhidden:focus {
clip: auto;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
}
}
// Invisible
%invisible {
visibility: hidden;
}
// Clearfix
@mixin clearfix {
*zoom: 1;
&:before,
&:after {
content: " "; /* 1 */
display: table; /* 2 */
}
&:after {
clear: both;
}
}
@ryanburnette
Copy link
Author

I used to use HTML5 boilerplate and I still love the helpers that come with it. I use them constantly so I adapted this quick snippet to import in my Sass routines.

@ryanburnette
Copy link
Author

A couple of these need to be mixins and a couple can survive as just helper classes. Made those updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment