Reputation: 4419
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
}
Upvotes: 3
Views: 1509
Reputation: 1305
Dividing the percentage by 100% should give you a decimal which you can then multiply by the pixel value.
width: 100px * ((100% - $fooPercent) / 100%)
Upvotes: 5