Skip to content

Instantly share code, notes, and snippets.

@vish448
Created December 19, 2019 15:51
Show Gist options
  • Save vish448/2193457725775446ed25e3174a0d4824 to your computer and use it in GitHub Desktop.
Save vish448/2193457725775446ed25e3174a0d4824 to your computer and use it in GitHub Desktop.
scss Px to Vw function
@function pxToVw($px, $viewport) {
@return ($px * 100vw / $viewport);
}
@vish448
Copy link
Author

vish448 commented Dec 19, 2019

This function is very useful when you create layouts. As it resize elements according to view port. So you never have to fix the size.

Sample Usage
font-size pxToVw(16,1440) -- It will setup the font size to 16px to the viewport 1440 and adjust according to the smaller or bigger viewport

width: pxToVw(1000,1920); -- This will setup the width of an element to 1000px for the viewport of 1920

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