我使用display: table-cell
创建带有按钮的工具栏的somekind的:右对齐表格单元格位置
body {
margin: 0;
padding: 0
}
#docs {
color: #333
}
#docs .docs-header {
height: 40px;
background: #efefef;
padding: 0 20px;
}
#docs .docs-header-item {
height: inherit;
vertical-align: middle;
display: table-cell;
padding: 0 13px 0 5px;
font-size: 1.1em;
cursor: pointer;
}
#docs .docs-header-item:hover {
background: #e0e0e0
}
<div id="docs">
<div class="docs-header">
<div class="docs-header-item">
Item #1
</div>
<div class="docs-header-item">
Item #2
</div>
<div class="docs-header-item">
Item #3
</div>
<div class="docs-header-item">
Item #4
</div>
</div>
</div>
它运作良好,但我想一些对齐的那些按钮在杆的右侧,像项目#4下面的图片:
我无法使用float: right
工作,无论是position: absolute; right: 0
还是.docs-header-item
。这甚至可能没有重大变化?
看看引导CSS,看看他们怎么'拉right' –
@MarkSchultheiss它只是使用'浮动:right'。我试过了,但是它弄乱了布局。 – DontVoteMeDown
是的,你必须看看整个CSS,以及它们如何设法使用那里的'pull-right'类。一种选择是只包含该CSS,但可能比您想要/需要的要多。 –