如何居中div元素?他们只漂浮在彼此旁边,但不要居中。浮动左div容器中心
div元素都包含一个固定宽度的图片,图片下方出现一个变量文本。
<div id="wrapper">
<div style="max-width:900px;margin: 0 auto;">
<div style="width:100%;">
<div style="float:left;"><img src="img" width="250" height="150" ><br>This text goes under the Picture.</div>
<div style="float:left;"><img src="img" width="250" height="150" ><br>This text goes under the Picture.</div>
<div style="float:left;"><img src="img" width="250" height="150" ><br>This text goes under the Picture.</div>
<div style="float:left;"><img src="img" width="250" height="150" ><br>This text goes under the Picture.</div>
<div style="float:left;"><img src="img" width="250" height="150" ><br>This text goes under the Picture.</div>
<div style="float:left;"><img src="img" width="250" height="150" ><br>This text goes under the Picture.</div>
<div style="float:left;"><img src="img" width="250" height="150" ><br>This text goes under the Picture.</div>
</div>
</div>
</div>
#wrapper{
margin: 0 auto;
width: 900px;
max-width: 100%;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
谢谢。
问候
也很有魅力,非常感谢! –
@MarcoVeLi真棒,没问题:) –