1
Well, I’m doing a site where in the home there are 4 modules, the first two have to be under each other, so far so good, except that the third module has to be next to these two as if it were a column, First I thought I’ll put a div around the two and it even worked, but then another problem arose, the 4 module would have to stay below the 1 and 2 only that in the layout I received, the mobile version is in that order where the 4 module has to be under the column of the non-mobile version, so my question is:
- In the version where I create a div to involve the first two modules, as I do for the 4 module to occupy the empty space?
In the version where I do not create a div to involve the first two, there is a way for the first two to stay under each other the 3 next to the two and the 4 occupying the empty space below the first two?
Remembering that I am using FLEX-BOX but if you have a better alternative I accept suggestions.
I’ll put an image to illustrate how it should look
FINAL SOLUTION
Instead of using flexbox I used the float property even as follows:
CSS
.pai{ float:left} Largura qualquer
.pai .mod{ width:704px; float:left;}Envolve o módulo1 e 2()
.pai .modulo3{ width:296px; float:right; }Mod3 ocupa o lado direito
.pai .modulo4{ width:704px; float:left; }Ocupará o espaço vazio
HTML
<div class="pai">
<div class="mod">
<div class="modulo1"></div>
<div class="modulo2"></div>
</div>
<div class="modulo3"></div>
<div class="modulo4"></div>
</div>
I’ll try here thanks
– user4451
Okay, just one observation, with flex-box there is no way to do it right? Only with GRID?
– user4451
blz, I just resorted here pq I’ve researched a lot of place and haven’t found exactly what I need, I’m even trying Nth-Child but I think it’s not working
– user4451
I tested the grid method until it worked, except that the contents will distribute their height evenly with the column
– user4451
Well, it worked, I was just cracking my head here, only one last thing is that the way you made the column and the other kids got stuck sideways so I put a width for the column and for the rest of it, only that the column was not on the right and yes in the middle I could only put on the right qdo I gave a margin-left, is that there is some way to specify that only the column is on the right with flex-box?
– user4451
That’s right, vlw bro, I still need to learn a lot about flex-box
– user4451
One last thing this stretch "flex: 0 0 100%;" leaves the height of the giant column and only comes out if I take the 100%, only then it is no longer on the side
– user4451
It didn’t work :( what happens is that when he goes to the side he keeps kind of a ghost of the same height as if he was still there, I tried overflow:Hidden; Justify-self:start but nothing
– user4451
@user4451 the problem is in leaving the father div at the height of the sum of the 3 left Ivs... I don’t really have much mastery over the flex-box. But one solution would be to apply height in the parent div by javascript:
divpai = document.querySelector('.pai');divfil = divpai.offsetHeight-document.querySelectorAll('.pai > .filhos')[3].offsetHeight;divpai.style.height = divfil+'px';
– Sam