Last active
October 19, 2016 08:57
-
-
Save ralexandr/a3c47880008755293af15e74b5f81b2b to your computer and use it in GitHub Desktop.
SASS: Responsive ratio
This file contains 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
// use this for creating scalable elements (usually images / background images) that maintain a ratio. | |
// @include responsive-ratio(16,9); | |
@mixin responsive-ratio($x,$y, $pseudo: false) { | |
$padding: unquote( ( $y / $x ) * 100 + '%' ); | |
@if $pseudo { | |
&:before { | |
@include pseudo($pos: relative); | |
width: 100%; | |
padding-top: $padding; | |
} | |
} @else { | |
padding-top: $padding; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment