-
-
Save lucianobarauna/45dbd6d876a57474d5013f1e3945683f to your computer and use it in GitHub Desktop.
PX TO REM FUNCTION in SASS - Convert px value to rem easily in SASS
This file contains 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
// SASS FUNCTION TO CONVERT PX INTO REM | |
// Defining base font size | |
// The default font size for html is 16px | |
$base-size: 16; | |
//Function to convert px value into rem | |
//You can replace rem with any other value you want (rem is most preferred value for web) | |
@function size($target, $context: $base-size) { | |
@return ($target / $context) * 1em; | |
} | |
// Let's use the size whenever you want | |
body { | |
margin: size(20); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment