Html 右对齐 div 内的内联 UL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/4781733/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Right Align an inline UL which is inside a div
提问by Adil
I have a pagination output which is show within
我有一个分页输出,显示在
The ul is wrapped around 2 divs
ul 被 2 个 div 包裹
1st div is 550 width 2nd div called "paginationDiv" basically wraps the ul around
第一个 div 是 550 宽度第二个 div 称为“paginationDiv”基本上环绕 ul
The ul has list-style: none. What I am trying to do is make it float right, but it keeps appearing as a block. I have tried quite a few things but nothing seems to work. If I add a width to the paginationDiv then it works but it's not accurate because it will never be fixed width
ul 具有列表样式:无。我想要做的是让它正确浮动,但它一直显示为一个块。我已经尝试了很多东西,但似乎没有任何效果。如果我向 paginationDiv 添加宽度,那么它可以工作,但它不准确,因为它永远不会是固定宽度
Here is what it looks like:
这是它的样子:
<div class="parentDiv">
   <div class="paginationDiv">
      <ul id="paginationLinks">
        <li>Page 1</li>
        <li>Page 2</li>
      </ul> 
    </div>
 </div>
That's the html code
这是html代码
Here is the css:
这是CSS:
div.parentDiv { 
  width: 550px; 
}
div.paginationDiv {
  float: right;
}
#paginationLinks ul {
  border: 0;
  padding: 0;
  margin: 0;
}
#paginationLinks li {
  list-style: none;
}
I have posted an example here: http://jsfiddle.net/6N4bD/1/
我在这里发布了一个例子: http://jsfiddle.net/6N4bD/1/
采纳答案by Mahima
give float:leftto #paginationLinks liand then see the result
给float:left到#paginationLinks li,然后看看结果
回答by Chris
What seems to work is adding display: inline;to the li elements.
似乎有效的是添加display: inline;li 元素。
http://jsfiddle.net/XFdqT/has a demo of this.

