Skip to content

Instantly share code, notes, and snippets.

@roryashfordbentley
Created January 4, 2015 17:44
Show Gist options
  • Save roryashfordbentley/897fcaecc1d0cfa0f3f2 to your computer and use it in GitHub Desktop.
Save roryashfordbentley/897fcaecc1d0cfa0f3f2 to your computer and use it in GitHub Desktop.
Sass mixin to make element a fixed aspect ratio
/**
* _aspect-ratios.scss
*
* Mixin to display block level elements at
* fixed aspect ratios using padding top
* on an :after pseudo element.
*/
@mixin aspect-ratio($h,$v){
&:after{
padding-top: ($v / $h) * 100%;
display: block;
content: '';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment