0
We created this code below to simulate the same problem on a site I’m developing to practice my html and css. I have two elements that float to the left and one to the right but when I clear the float of the second element the third element (right) is pushed down. how do I fix this? html:
<div class="primeiro"></div>
<div class="segundo"></div>
<div class="terceiro"></div>
**css:**
div{
width: 20px;
height: 20px;
background: pink;
border: 2px solid black;
}
.primeiro{
float: left;
}
.segundo{
float: left;
clear: left;
}
.terceiro{
float: right;
}
The third comes after the second, so it will be on the same line as the second. You wanted the third to be on the same line as the first?
– Sam
blz.... did not know that floating elements respected hierarchy... Valew
– Geraldo Henrique
Dude, in this case it’s not even hierarchy, it’s the flow of the same elements. They’re brothers, there’s no hierarchy. At least I understand hierarchy as father and sons, a tree.
– Sam
The answer didn’t answer? Is there a problem? Please ask or mark to give the question as solved. Abs!
– Sam