我知道您可以通过将左右边距设置为auto.
但是,是否可以将其与右边缘对齐?这将如何完成?
编辑:不使用float: right(因为它似乎不起作用,至少不使用<ul>'s)
再次编辑:这是代码片段:
<td style='vertical-align: top; text-align: center;'>
<b>Choices:</b><br><br>
<ul id='orderchoices' style='margin-left: auto; margin-right: auto;'>
...
</ul>
</td>
Run Code Online (Sandbox Code Playgroud)
这是样式 #orderchoices
#orderchoices li {
border: 1px solid #666;
background: #333 url(images/dark_gloss.png) repeat-x;
color: #eee;
margin: 3px;
padding: 5px;
cursor: pointer;
width: 160px;
font-style: italic;
}
Run Code Online (Sandbox Code Playgroud)
我想要ul右对齐td
<div class="outer">
<div class="inner">I'm the inner element!</div>
</div>
<style type="text/css">
.outer { position:relative; }
.inner { position:absolute; right:0px; }
</style>
Run Code Online (Sandbox Code Playgroud)
如果你内心的元素是相对定位的一个容器内绝对定位,你可以使用top,right,bottom并left指示从父容器边缘的内部元件的距离。
有道理?