Created
September 12, 2018 20:31
-
-
Save Tenderfeel/b17963f6491962d91e5c7e8c6f71ab55 to your computer and use it in GitHub Desktop.
Sass Responsive Mixins
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
@function percentage-vw($num) { | |
$per: ($num * 100); | |
@return #{$per}vw; | |
} | |
@mixin responsive-width($width, $base: 750px) { | |
width: percentage($width / $base); | |
max-width: $width; | |
} | |
@mixin responsive-height($width, $height) { | |
height: percentage($height / $width); | |
max-height: $height; | |
} | |
@mixin responsive-spacer($width, $height) { | |
&::before { | |
content: ''; | |
display: block; | |
padding-top: percentage($height / $width); | |
float: left; | |
} | |
} | |
//@include responsive(image-width($img), image-height($img)); | |
@mixin responsive($width, $height, $base: 750px, $size: true, $spacer: true) { | |
@if ($size == true) { | |
background-size: contain; | |
} | |
width: percentage($width / $base); | |
max-width: $width; | |
max-height: $height; | |
overflow: hidden; | |
@if($spacer == true) { | |
@include responsive-spacer($width, $height); | |
} | |
} | |
@mixin clear-responsive() { | |
max-width: 100%; | |
max-height: 100%; | |
&::before { | |
display: none; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment