I have the following situation:
div {
width: calc((100% / 11) - 9.09px);
}
In the context, 100%
= 1440px
, and <
Unfortunately, there is not a native way in CSS to round (or ceil/floor) numbers.
However — you mentioned you are using Sass. I found a small Sass library that can round, floor, and ceil numbers to a specified precision.
For example, if you had a had 94.546
you could use decimal-floor(94.546, 2)
which would return 94.54
.
Unfortunately, this might not help if you have to use calc()
to calculate on the fly with CSS. However, if you can pre-calculate the width
and floor it with Sass it would fit your needs. A possible solution could be using @media
queries as a way to set breakpoints and use those breakpoints in your Sass preprocessing.