Skip to content

Instantly share code, notes, and snippets.

@denised
Created April 23, 2016 20:25
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 denised/14f8b4c99a3125d52730b86efa5cce0f to your computer and use it in GitHub Desktop.
Save denised/14f8b4c99a3125d52730b86efa5cce0f to your computer and use it in GitHub Desktop.
Simple Sass mixin for responsive css: start height / width / margin / font-size/etc. at one size, and shrink when the screen is smaller.
/*
* Set a measure to a standard size on large screens,
* and beneath 750 pixels width, scale it according to screen width.
* Useful for margins, padding, font-sizes: anything which takes a measure.
* Works with absolute measures (px, pt, etc., also rem), not
* with relative measures (em, etc.)
*
* Usage:
* foo {
* @include responsive-measure(margin,20px);
* }
*/
@mixin responsive-measure($measure,$basis) {
#{$measure}: $basis;
@media (max-width: 749px) {
$unitless: $basis / (0 * $basis + 1);
#{$measure}: $unitless * 0.1333vw;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment