我有一个底部的工具栏,如下所示:
<div style="float:left;width:100%;position:fixed;z-index:210;bottom:5px;">
<div style="float:left;width:928px;border:1px solid #000;background:url('/images/noise-bg.jpg') repeat-x;height:26px;padding:5px;">
Toolbar Content
<div>
</div>但此工具栏在页面的左侧对齐。我要把这个DIV放在页面的中央。表示工具栏两侧(左侧和右侧)的相同空间区域。我不能固定工具栏的宽度,它总是100%。我尝试通过设置固定的margin-left,但它在不同的浏览器/分辨率和iPad上是不同的。有什么想法吗?
谢谢
发布于 2012-01-18 20:18:19
你的div有width:100%和float:left,所以它和你的页面大小一样,你不能居中。
正确设置宽度,删除浮动,并在div上应用margin: 0 auto规则使其居中。
我做了一个jsbin来展示它的工作:
http://jsbin.com/obepad/2/edit
https://stackoverflow.com/questions/8909960
复制相似问题