Skip to content

Instantly share code, notes, and snippets.

@mammuth
Created October 31, 2018 13:22
Show Gist options
  • Save mammuth/8890b2832fab165c4f3f64e0c92cc8fe to your computer and use it in GitHub Desktop.
Save mammuth/8890b2832fab165c4f3f64e0c92cc8fe to your computer and use it in GitHub Desktop.
Less aspect ratio mixin
.m-aspect-ratio (@width, @height) {
position: relative;
&:before {
display: block;
content: "";
width: 100%;
padding-top: (@height / @width) * 100%;
}
> .content {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
}
/* Usage:
* .my-wrapper {
* .m-aspect-ratio(16, 9);
* }
* Give child content in .content class
*/
@davidjeams
Copy link

Wow! Thanks for this..

godaddy domain at 99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment