【发布时间】:2013-08-10 05:02:40
【问题描述】:
我需要做一个由左箭头按钮、一组图像按钮和右箭头按钮组成的工具栏
我的要求是:
工具栏需要在一行
工具栏需要水平居中
该集合可以有许多图像按钮(N 未知)
当窗口宽度太小时,中间的 div 应该隐藏不适合的图像按钮
为了将所有内容水平居中,我发现这在 chrome 上运行良好:
<div style="display:-webkit-box; -webkit-box-pack:center; -webkit-box-align:center;" class="toolbar">
<button>LEFT</button>
<div style="overflow:hidden;">
<button style="height:72px">1</button>
<button style="height:72px">2</button>
<button style="height:72px">3</button>
<button style="height:72px">4</button>
<button style="height:72px">5</button>
<button style="height:72px">6</button>
<button style="height:72px">7</button>
<button style="height:72px">8</button>
<button style="height:72px">9</button>
</div>
<button>RIGHT</button>
</div>
但不幸的是,盒子参数打破了溢出:如果中间集变得太大而无法容纳所有东西时所必需的隐藏样式。
那么还有另一种方法可以水平居中吗?
【问题讨论】:
-
Buttons:
position:relative;float:left添加一个边距,这样按钮就不会被压缩;outer divmargin:0 auto -
我想左和右按钮将允许用户滚动任何隐藏的图像/按钮?