Is it possible to round the width of an element to a number divisible by 8 less?

I am trying to make a chessboard with one element. It is located inside the container. I want the width and height to be divisible by 8 when resizing the page.

So, I thought you would get the eighth width (12.5%), round to the nearest pixel, and then multiply by 8 again. Is this possible?

So far, I:

@eighth: 12.5%;
@rounded: floor(@eighth);
@multiplied: @rounded * 8;

But this gives the result in percent (96%), and not in pixels. Is it possible to convert from percent to pixels first?

+4
source share
2 answers

, LESS, , LESS CSS, , -. , CSS -.

+1

, , CSS calc()

width: calc(12.5% / 8);

:

, @MarkSchultheiss, , , LESS calc(12.5% / 8) .

( @MarkSchultheiss):

0

Source: https://habr.com/ru/post/1629242/


All Articles