1
I have a div
father with several divs
son inside.
And I would like the Divs with the blue class to be on the right and the white class to be on the left. But next to each other, as in a row.
Setting the class to float left and right is a gap between.
.pai{
width: 300px;
border: 1px solid black;
height: 50px;
}
.filho{
width: 40px;
margin: 2px;
border: 1px solid black;
}
.azul{
float:left;
background-color: blue;
}
.branco{
float:right;
background-color: white;
}
<div class='pai'>
<div class='filho azul'>texto</div>
<div class='filho branco'>texto</div>
<div class='filho azul'>texto</div>
<div class='filho azul'>texto</div>
<div class='filho branco'>texto</div>
<div class='filho branco'>texto</div>
<div class='filho branco'>texto</div>
<div class='filho azul'>texto</div>
</div>
I’d like to keep it that way, but I don’t control the order of the Ivs.
.pai{
width: 300px;
border: 1px solid black;
height: 50px;
}
.filho{
width: 40px;
margin: 2px;
border: 1px solid black;
}
.azul{
float:left;
background-color: blue;
}
.branco{
float:left;
background-color: white;
}
<div class='pai'>
<div class='filho azul'>texto</div>
<div class='filho azul'>texto</div>
<div class='filho azul'>texto</div>
<div class='filho azul'>texto</div>
<div class='filho branco'>texto</div>
<div class='filho branco'>texto</div>
<div class='filho branco'>texto</div>
<div class='filho branco'>texto</div>
</div>
How to do ?
Can be with flex?
– hugocsl
I thought about it, but I tried to apply it to the father div, it didn’t work out so well. Can you give me an example ?
– Pedro Augusto