Skip to content

Instantly share code, notes, and snippets.

@zoxon
Created July 16, 2018 10:39
Show Gist options
  • Save zoxon/6959c85384ec3fd5a5c4ab64b2768ed2 to your computer and use it in GitHub Desktop.
Save zoxon/6959c85384ec3fd5a5c4ab64b2768ed2 to your computer and use it in GitHub Desktop.
SCSS mixins
@mixin clearfix {
&:after {
content: '';
display: table;
clear: both;
}
}
@mixin visuallyhidden {
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
margin: -1px;
padding: 0;
border: 0;
}
@mixin below($measure) {
@media screen and (max-width: #{$measure}) {
@content;
}
}
@mixin above($measure) {
@media screen and (min-width: #{$measure}) {
@content;
}
}
@function strip-unit($number) {
@if type-of($number) == 'number' and not unitless($number) {
@return $number / ($number * 0 + 1);
}
@return $number;
}
$browser-context: 16px;
@function em($pixels, $context: $browser-context) {
@return #{strip-unit($pixels) / strip-unit($context)}em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment