divs
floating left, but when it reaches the fifth div
in 1000px
, it floats on the right and not on the left as should be and margin-top
is greater for all subsequent divs
, ie from the fifth element, the divs
are with a large spacing at its top.
See the example below:
AndIwantthemtolooklikethis:
AndthecodeI'musingisthis:
HTML
<divclass="center">
<div class="boxpost">
<img src="https://33.media.tumblr.com/26bf1c7107a9a765bd28aeabd15dfec5/tumblr_nwyd2kKcpH1u24qqvo1_400.gif"width="239px"/>
</div>
<div class="boxpost">
<img src="https://33.media.tumblr.com/26bf1c7107a9a765bd28aeabd15dfec5/tumblr_nwyd2kKcpH1u24qqvo1_400.gif"width="239px"/>
</div>
<div class="boxpost">
<img src="https://33.media.tumblr.com/26bf1c7107a9a765bd28aeabd15dfec5/tumblr_nwyd2kKcpH1u24qqvo1_400.gif"width="239px"/>
</div>
<div class="boxpost">
<img src="https://33.media.tumblr.com/26bf1c7107a9a765bd28aeabd15dfec5/tumblr_nwyd2kKcpH1u24qqvo1_400.gif"width="239px"/>
</div>
<div class="boxpost">
<img src="https://33.media.tumblr.com/26bf1c7107a9a765bd28aeabd15dfec5/tumblr_nwyd2kKcpH1u24qqvo1_400.gif"width="239px"/>
</div>
<div class="boxpost">
<img src="https://33.media.tumblr.com/26bf1c7107a9a765bd28aeabd15dfec5/tumblr_nwyd2kKcpH1u24qqvo1_400.gif"width="239px"/>
</div>
<div class="boxpost">
<img src="https://33.media.tumblr.com/26bf1c7107a9a765bd28aeabd15dfec5/tumblr_nwyd2kKcpH1u24qqvo1_400.gif"width="239px"/>
</div>
<div class="boxpost">
<img src="https://33.media.tumblr.com/26bf1c7107a9a765bd28aeabd15dfec5/tumblr_nwyd2kKcpH1u24qqvo1_400.gif"width="239px"/>
</div>
</div>
CSS
.center{
margin: 0 auto;
width:1024px;
}
.boxpost{
width:245px;
overflow:auto;
background-color: #f7f7f7;
border-radius: 3px;
float:left;
margin-top: 10px;
margin-left: 10px;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19) !important;
padding-bottom: 5px;
}
.profilepost{
float: left;
width: 100%;
height:50px;
border-bottom:1px solid #CCCCCC;
}
The problem is that I have to take the heights and always put the auto overflow, because they can come images of different sizes, and even for the aesthetics of the business to be more relaxed then I put auto overflow and we have a new problem, the divs are mixed, type 4 divs with different images, the fourth div becomes the second on the site, and everything gets messed up.