I use the same "icon" class to justify the instagram icon image and yg entertainment logo image.
But why yg entertainment logo is at the different position with the instagram icon?
<div class="incormation">
<div class="instagram">
<img class="icon" src="instagram.png"><a href="https://www.instagram.com/jennierubyjane/">J(@jennierubyjane)</a>
</div>
<div class="yg">
<img class="icon" src="yglogo.png"><a href="Codeit.kr">YG entertainment</a></div>
.icon{
width: 22px;
margin: 0px 6px auto;
display: block;
float: left;
}
.instagram > a {
text-decoration: none;
color: #2A2F4F;
}
.allbums{
width: 140px;
height: 140px;
margin-right: 4px;
}
.yg > a {
text-decoration: none;
color: #2A2F4F;
}
2
Answers
To position an element below a floated element, the clear property needs to be used.
In your case:
The alignment issue is due to the images being floated left. The second image doesn’t clear the first one, therefore the second image is positioned to the right of the first one.
However, I see no need to use
float: left
. The images are already contained inside a block-leveldiv
, and you can reduce the HTML by just using a line break<br>
.