Created
July 31, 2024 04:44
-
-
Save agronom81/d0385a0696bef6372848aa46b5f3d4c4 to your computer and use it in GitHub Desktop.
Sass/SCSS function to convert from px to rem
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
/* Usage -- font-size: rem(16) */ | |
@use 'sass:math'; | |
@function rem($pixel) { | |
@if math.is-unitless($pixel) { | |
@return math.div($pixel, 16) + rem; | |
} @else { | |
@error 'Don\'t use units when using the rem() function; only numbers.'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment