Last active
February 7, 2017 14:58
-
-
Save iamnewton/bd643fd3fb255caec5f8 to your computer and use it in GitHub Desktop.
Maintain Aspect Ratio mixin (https://css-tricks.com/snippets/sass/maintain-aspect-ratio-mixin/)
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
@mixin 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; | |
} | |
} |
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
<div class="sixteen-nine"> | |
<div class="content"> | |
insert content here | |
this will maintain a 16:9 aspect ratio | |
</div> | |
</div> |
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
.sixteen-nine { | |
@include aspect-ratio(16, 9); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and with images how???