Can this be achieved using the flex —or grid— model? Or I must rewrite the structure using a different approach?
This is the code:
.sections {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
margin: 0em -1em 2em -1em;
}
.box {
position: relative;
display: inline-block;
flex-grow: 0;
min-width: 300px;
max-width: 420px;
margin: 1em;
border-radius: 10px;
padding: 1em;
vertical-align: top;
}
.elements {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin: 1em 0em 0em 0em;
}
.itm {
position: relative;
display: inline-block;
flex-grow: 0;
width: 100px;
margin: 1em;
text-align: center;
border-radius: 10px;
box-shadow: 0px 5px 8px 2px rgb(0 0 0 / 20%);
padding: 0.5em;
vertical-align: top;
}
<div class="section">
<div class="box">
<p>Long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text </p>
<div class="elements">
<div class="itm">
<p>asdf asdf</p>
</div>
<div class="itm">
<p>asdf asdf</p>
</div>
<div class="itm">
<p>asdf asdf</p>
</div>
</div>
</div>
<div class="box">
<p>Medium text medium text medium text medium text medium text medium text medium text medium text medium text medium text medium text </p>
<div class="elements">
<div class="itm">
<p>asdf asdf</p>
</div>
<div class="itm">
<p>asdf asdf</p>
</div>
<div class="itm">
<p>asdf asdf</p>
</div>
</div>
</div>
<div class="box">
<p>Short text short text </p>
<div class="elements">
<div class="itm">
<p>asdf asdf</p>
</div>
<div class="itm">
<p>asdf asdf</p>
</div>
<div class="itm">
<p>asdf asdf</p>
</div>
</div>
</div>
</div>