Created
August 18, 2018 13:13
-
-
Save samandera/2e1fd2b2416d92b1d1f4c1a33c5ca74e to your computer and use it in GitHub Desktop.
Functions and mixins to easily set properties for fluid layout.
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
| $minresolution: 320px; | |
| $desktop-resolution: 1024px; | |
| @function strip-form-unit($value) { | |
| @return $value/($value*0+1); | |
| } | |
| @function min-resolution-percentage($value) { | |
| @return #{$min-resolution * strip-form-unit($value) / 100}; | |
| } | |
| @mixin responsive-properties( | |
| $coordinates-property, | |
| $mobile-coordinates, | |
| $desktop-coordinates | |
| ) { | |
| @if $mobile-coordinates != null { | |
| $values: (); | |
| @each $value in $mobile-coordinates { | |
| @if type-of($value) == number {$value: min-resolution-percentage($value)} | |
| $values: append($values, $value); | |
| } | |
| #{$coordinates-property}: $values; | |
| @if $mobile-coordinates !=0 { | |
| @media screen and (min-width: $min-resolution) { | |
| #{$coordinates-property}: $mobile-coordinates; | |
| } | |
| } | |
| } | |
| @media screen and (min-width: $desktop-resolution) { | |
| #{$coordinates-property}: $desktop-coordinates; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment