Last active
July 19, 2021 19:47
-
-
Save awestmoreland/5554996 to your computer and use it in GitHub Desktop.
Concatenation of sass value+units.
See also: http://stackoverflow.com/a/9862328
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
// Set sizes without units | |
$basefont: 20; | |
$total-width-px: 1169; | |
$column-width-px: 72; | |
// Concatenation of units by addition results in conversion to string. This is bad | |
$basefont-px: $basefont+'px'; // = "20px" | |
// Conversion to pixels using multiplication | |
$basefont-px: $basefont*1px; // = 20px; | |
// Conversion to percentages using multiplication | |
$column-width: ($column-width-px/($total-width-px/100))*1%; // = 6.159110351%; |
Great, thanks π
There's also the unquote
function:
$value + unqoute("%")
thanks
Thanks
Thanks πππ
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx, you saved my day ;]