Skip to content

Instantly share code, notes, and snippets.

@toddpress
Last active August 29, 2015 13:59
Show Gist options
  • Save toddpress/10570458 to your computer and use it in GitHub Desktop.
Save toddpress/10570458 to your computer and use it in GitHub Desktop.
Maintain element's aspect ratio like a baller
.aspectRatio(@widthAspect, @heightAspect) {
@aspect: @heightAspect/@widthAspect * 100;
max-width: 100%;
&:before {
content: '';
display: block;
width: 100%;
padding-bottom: ~"@{aspect}%";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment