Created
December 19, 2019 15:51
-
-
Save vish448/2193457725775446ed25e3174a0d4824 to your computer and use it in GitHub Desktop.
scss Px to Vw function
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
@function pxToVw($px, $viewport) { | |
@return ($px * 100vw / $viewport); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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