L
L
lolka022020-04-14 13:34:27
css
lolka02, 2020-04-14 13:34:27

Is it possible to make the width of elements responsive based on the parent container?

for example

<div class="content">
    <div class="child-box"></div>
    <div class="child-box"></div>
    <div class="child-box"></div>
    <div class="child-box"></div>
</div>


Let's say content has a width of 600, respectively, make child-box 150 if there are 4 of them, if 3 then 200 each, and so on? in pure css maybe? Or will you have to calculate and set the width of the child-box elements on js?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wendem, 2020-04-14
@wendem

Yes it's easy use width: calc(100% / 3);
Well, etc. 3 - the number of blocks in the rows

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question