Created
January 4, 2015 17:44
-
-
Save roryashfordbentley/897fcaecc1d0cfa0f3f2 to your computer and use it in GitHub Desktop.
Sass mixin to make element a fixed aspect ratio
This file contains hidden or 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
/** | |
* _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