In one case, I need to combine a percentage variable with pixels in calculation.
Note It's not about keeping mixed units in generated css, so calc wouldn't work.
$fooPercent: 40%;
.abc {
width: 100% - $fooPercent; // This works
}
.bar {
width: 100px * (100% - $fooPercent); // Intend to get 60px
}
Dividing the percentage by 100% should give you a decimal which you can then multiply by the pixel value.
width: 100px * ((100% - $fooPercent) / 100%)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With