【发布时间】:2013-04-03 17:17:24
【问题描述】:
我正在尝试在我的页面上居中浮动图像,但我无法让它工作。这是我的代码
.imcontainer {
text-align:center;
display:inline-block;
}.float {
float: left;
font-size: small;
height: auto;
margin: 5px 7px 0 3px;
width: auto;
}
HTML
<div class="imcontainer">
<div class="float"><img width="70px" height="70px" src="image.jpg"></div>
<div class="float"><img width="70px" height="70px" src="image.jpg"></div>
<div class="float"><img width="70px" height="70px" src="image.jpg"></div>
<div class="float"><img width="70px" height="70px" src="image.jpg"></div>
<div class="float"><img width="70px" height="70px" src="image.jpg"></div>
</div>
我该如何解决这个问题?
【问题讨论】:
-
你几乎错过了所有
</div> -
如果这是您的实际代码,请注意浮动 div 都在彼此内部。这是设计使然吗?
-
你必须先给
floatdiv 固定宽度 -
抱歉,我没有正确复制代码。马上更新