Created
November 29, 2016 10:54
-
-
Save yuheiy/a50c5072866e6223a6a72d5082f00911 to your computer and use it in GitHub Desktop.
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
$width-comp-size: 640px; | |
@function strip-unit($n) { | |
@return $n / ($n * 0 + 1); | |
} | |
@function w($size) { | |
$width: $size / $width-comp-size * 100%; | |
@return $width; | |
} | |
@function m($size) { | |
$margin: calc(100vw * #{strip-unit($size)} / #{strip-unit($width-comp-size)}); | |
@return $margin; | |
} | |
.foo { | |
width: w(125px); | |
} | |
.bar { | |
margin-bottom: m(20px); | |
} | |
.baz { | |
width: w(40px); | |
margin-bottom: m(270px); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment