16.9 Operators
As briefly mentioned in the previous section, you can also use the calculation operators +, -, *, /, and % (modulo) with Sass. It can be quite useful to have the values calculated during the design and layout. Here’s an example that demonstrates a few ways you can use operators in Sass. I used this example in the context of media queries and adjusted a few properties with simple calculations.
|
SCSS File |
CSS File |
|---|---|
|
...$article-width: 80%;$font-increase: 0.125em;$base-size: 1;....my-article { font-family: $font;font-size: $base-size * 1em;padding: $base-size * 1em; background-color: lightgray; margin: 1em; @include breakpoint($mq-mobile) {font-size: $base-size + $font-increase; |
.my-article { font-family: "Franklin ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access