Reputation: 556
I've tried many times and it couldn't work at all. I need the float images in the centered inside the div. So I don't need to do padding and margin. It will be automatically nice when I put another images.
HTML
<div class="section-global">
<p class="red"> HELLO </p>
<p>
<ul class="image-global">
<li>
<img src="assets/images/welcome.jpg" />
<p> ABC </p>
</li>
<li>
<img src="assets/images/welcome.jpg" />
<p> ABC </p>
</li>
<li>
<img src="assets/images/welcome.jpg" />
<p> ABC </p>
</li>
<li>
<img src="assets/images/welcome.jpg" />
<p> ABC </p>
</li>
</ul>
</p>
</div>
CSS
.section-global {
margin:10px 0;
border:1px solid #F63;
overflow:hidden;
}
.section-global p {
padding:10px;
}
.image-global {
text-align:center;
}
.image-global li {
float:left;
display:inline-block;
}
.image-global img {
width:125px;
height:125px;
margin:0 auto;
}
and here is JSFIDDLE. Any ideas?
Upvotes: 2
Views: 72
Reputation: 3932
You should use only display: inline-block;
and remove float: left;
on your .image-global li
class.
I have also added negative margin to close the gaps.
.image-global li {
display: inline-block;
margin-right: -4px;
}
Upvotes: 0
Reputation: 2897
You don't have to float the list items left if you have used display: inline-block
and text-align: center
.
If I am correct, this is what you want, right?
Just removed the float on
.image-global li {
display:inline-block;
}
Upvotes: 3