I am trying to use Sass (and Compass) to simplify the creation of a percentage-width layout.
Using the formula from A List Apart of target/context=result
, where the context is 980px and the design width is 640px, I tried doing a rule of
#leftcol {
width: ((640/980)*100%);
}
Which compiles to
#leftcol {
width: 65.306%;
}
Is there an easier way than to do that without typing that over and over?
No mixin needed. Sass has a built-in percentage function that accepts a variety of units.
width: percentage(640 / 980)
width: percentage(640px / 980px)
both result in:
width: 65.30612%
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