如何将块项目与其父项的右边缘对齐(使用 CSS)?

Nat*_*man 3 css alignment

我知道您可以通过将左右边距设置为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

ink*_*dmn 5

<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)

如果你内心的元素是相对定位的一个容器内绝对定位,你可以使用toprightbottomleft指示从父容器边缘的内部元件的距离。

有道理?