1
Hello, I’m having a question about the alignment of div. I have a situation where I have several Divs within one another. I want the internal Ivs to be aligned to the center, but when there is line break, the div that went to the second line go to the position on the left, exactly below the first div in the first line.
Only to do this also I can not use predefined width and height, because I want the outside div to auto fit.
Follow an example of the situation that I have currently:
.fora {
background-color: black;
width: auto;
height: auto;
padding: 30px;
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
align-items: flex-start;
align-content: flex-start;
margin: 0 auto;
}
.quadrado {
width: 90px;
height: 90px;
background-color: gray;
float: left;
margin: 10px;
align-self: flex-start;
}
<div class="fora">
<div class="quadrado"></div>
<div class="quadrado"></div>
<div class="quadrado"></div>
<div class="quadrado"></div>
<div class="quadrado"></div>
<div class="quadrado"></div>
</div>
The space on the right edge is larger than the left edge, what I would like is for the spacing between the edges to remain the same.
I appreciate the help.
This link will make it easier to see the situation: https://jsfiddle.net/jarlan/34fns1uc/21/
– Jarlan
Dude if I got it right, I guess the math won’t let me. Yeah, if you have a father div wide auto, or is will adjust to the size of the window and placed the daughters with width of Divs 90px, will have time that window will not fit another daughter div on the same line, soon, will throw the daughter div down, getting that space.
– LeAndrade
But it’s okay to break the line, what I wanted is just that when I broke the line, it wouldn’t be disproportionate to the size of the edges. And if I align the internal elements will look like this: div1 div2 div3 <here breaks the line> div4 (below div2) what I wanted is for it to look like this: div1 div2 div3 <here breaks the line> div4 (below div1) only that this second option with same distance at left and right edges.
– Jarlan