【发布时间】:2012-09-05 18:13:40
【问题描述】:
我正在尝试实现一个 inline-block 元素,左对齐,另一个右对齐,而不改变它们的显示类型。
我想要一个 CSS 版本,否则我也可以使用 jQuery 方法。
我的意思是,我只是想显示前两个按钮在左侧对齐,第三个按钮在右侧对齐。
<table>
<thead>
<tr>
<th>
<div style="background-color: lightblue; width: 600px;">
<span style="display: inline-block; height:20px; background-color: red; margin: 5px 3px;float: left;">
Button
</span>
<span style="display: inline-block; height:20px; background-color: red; margin: 5px 3px; float:right;">
Button right
</span>
</div>
</th>
</tr>
</thead>
<tbody>
<tr><td>where did the background of the header cell go? the background is still there if the elements do not float.</td></tr>
</tbody>
</table>
【问题讨论】:
-
请在您的帖子中包含问题代码以及jsbin链接(meta.stackexchange.com/questions/84342/…)
-
左对齐是什么意思?是否将整个元素移动到左侧或其中的文本。
-
@SatyaTeja 我的意思是右对齐,我会更正帖子
-
但是,这些是内联的,没有设置宽度。如何对连续的内联元素进行交替对齐?目前尚不清楚您希望结果是什么样的。
-
@Toskan 请看一下,我已将您的按钮对齐在右侧。告诉我这是不是你要找的东西?