我有这段代码:
<style type="text/css">
body > div { height: 260px; overflow: hidden; }
div div { float: left; height: 250px; width: 250px; margin: 1px; background: #ccc; }
</style>
<div>
<div>first 1</div>
<div>first 2</div>
<div>first 3</div>
<div>first 4</div>
<div>first 5</div>
</div>
我想给这个盒子边缘以均匀地移动它们。
答案 0 :(得分:2)
由于容器的宽度未知,并且div的宽度以像素为单位固定(排除基于百分比的系统) - 您无法使用CSS执行此操作。
您可以使用http://matthewjamestaylor.com/blog/beautiful-css-centered-menus-no-hacks-full-cross-browser-support中描述的技术将它们居中,或者您可以查看JavaScript(或者您可以将父元素的宽度设置为已知值)。