如何让加了float:left的div居中?
<div class="div_1">
<div style="float:left">图像1</div>
<div style="float:left">图像2</div>
<div style="float:left">图像3</div>
</div>
让div_1下面的图像居中,我想的办法是在div_1的外面再加一个div,然后让div_1居中
<div class="div_out">
<div class="div_1">
<div style="float:left">图像1</div>
<div style="float:left">图像2</div>
<div style="float:left">图像3</div>
</div>
</div>
.div_out{text-align:center;}
但是,如果图像数量不固定 那么div_1的宽度要随着图像div的数量而决定 也就无法使用这种方法了。。。
有除了js以外的方法吗?
<div style="float:left">图像1</div>
<div style="float:left">图像2</div>
<div style="float:left">图像3</div>
</div>
让div_1下面的图像居中,我想的办法是在div_1的外面再加一个div,然后让div_1居中
<div class="div_out">
<div class="div_1">
<div style="float:left">图像1</div>
<div style="float:left">图像2</div>
<div style="float:left">图像3</div>
</div>
</div>
.div_out{text-align:center;}
但是,如果图像数量不固定 那么div_1的宽度要随着图像div的数量而决定 也就无法使用这种方法了。。。
有除了js以外的方法吗?
...全文
相关推荐
让横向排列的几个浮动(float:left)的子div居中显示
最后,将需要水平排列的浮动子div放入内层容器中,这些子div已经设置了float:left,所以会从左到右依次排列。
不用float实现div模块居中布局
不用float实现div模块居中布局在网页布局中,实现div模块居中的方法有很多,但是一般来说,使用float属性是最常见的方法之一。
如何用float配合position:relative实现居中
: hidden; margin: 15px auto 0; height: 10px;}.favViewicon ul { position: relative; float: left; left:
float:left的对象(导航)如何居中示例探讨
"本文主要探讨了在网页设计中如何使浮动(float)的对象,如导航条,实现水平居中。文章指出,使用`float:left`可以让元素自动适应内容宽度,但无法直接居中对齐。而`display:inli
Float 菜单水平居中简单方法
由于`#navigation`的父元素(假设是`body`或某个包含它的div)设置了`text-align:center`,所以`#navigation`会自动居中对齐。


