S
S
Sanchik972019-03-11 16:09:46
css
Sanchik97, 2019-03-11 16:09:46

Is it possible to calculate the block width depending on the number of all blocks?

Good afternoon! There is a wrapper whose width is 100%. Is it possible to somehow calculate the width of a child block using sass, depending on the number of these same blocks? For example, if we have 4 blocks, then their width will be 25% each, and so on...

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
RAX7, 2019-03-11
@Sanchik97

Maybe just layout on flexbox?
https://developer.mozilla.org/ru/docs/Learn/CSS/CS...

T
tommy_13, 2016-11-08
@Jacksnow

после каждого четного блока вставляем < div class="clearfix">< /div >

Виктор Таран, 2016-11-08
@shambler81

<col-6>
<col-6>
<div class="col-md-12></div>
<col-6>
<col-6>
<div class="col-md-12></div>
<col-6>
<col-6>

Cheap and cheerful and will always work.
All you need to do is to display in php every second element an empty div count 12, moreover, on the output.
no css no js no ajax
no absolutes no min max hat vidth and so on.
cheap and cheerful. example
www.mydefile.ru/catalog

S
Sergey, 2016-11-08
@Shull

You have a mistake in writing the image address in the block with id="block21". And something is wrong with the DIVs, the 1st, it seems, is superfluous. Also, no offense, the code is very overloaded. Also a terrible situation with id and class. Next, you specify the sizes of the images in the HTML code. Please do it with CSS.
Now to the process itself. Based on your CSS code, you line up blocks using margins and padding. With the current code, you can't even get the first picture, all the blocks are aligned in the center and go from top to bottom, one under the other. You didn't even write exactly how you want to align them. Always 2 blocks in a row? Or does it change with window size?
I simplified your code by throwing out things that are not related to the subject of discussion.
Maybe you like this behavior of blocks more? tyts!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question