Skip to content

Instantly share code, notes, and snippets.

@dospuntocero
Created February 9, 2018 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dospuntocero/c1e19dd3f57c13be83eb8fa4acfb8360 to your computer and use it in GitHub Desktop.
Save dospuntocero/c1e19dd3f57c13be83eb8fa4acfb8360 to your computer and use it in GitHub Desktop.
//px 2 vw - vh conversion tool
@function get-vw($object_width,$window_width:1440) {
$vw: ($window_width * 0.01) * 1px;
@return ($object_width / $vw) * 1vw;
}
@function get-vh($object_height,$window_height:768) {
$vh: ($window_height * 0.01) * 1px;
@return ($object_height / $vh) * 1vh;
}
@dospuntocero
Copy link
Author

added a default width and height so you can use the function just passing the value to compare with.
width: get-vw(200);
if you want to get a value using a different width (good for responsive layouts), you can use the second value
width: get-vw(100,320);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment