Html CSS 右对齐列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10431037/
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
CSS right aligned list
提问by lukas.pukenis
How should I align the list to the right? The text aligns perfectly, however bullets do not. Is there a simple and easy way to do so with CSS?
我应该如何将列表向右对齐?文本完美对齐,但项目符号不对齐。有没有一种简单易行的方法可以用 CSS 做到这一点?
Code:
代码:
<ul style="text-align: right">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
Even if I put the rules for LI elements directly to be aligned to the rigth, it does not work.
即使我将 LI 元素的规则直接与 rigth 对齐,它也不起作用。
EDITI have attached an image showing what I want to achieve:
编辑我附上了一张图片,显示了我想要实现的目标:
回答by Adriano Repetti
If you need to align the bullets with the text you can use the list-style-position
attribute, as follow:
如果您需要将项目符号与文本对齐,您可以使用该list-style-position
属性,如下所示:
.theList
{
text-align: right;
list-style-position: inside;
}?
回答by Madara's Ghost
Use direction:
使用方向:
direction: rtl;
It is generally used for right to left languages.
它通常用于从右到左的语言。
edit:
编辑:
Float each to the right and clear both.
将每个浮动到右侧并清除两者。
float: right;
clear: both;
回答by Jimmy Breck-McKye
If I understand your requirement correctly, then just right-floating the li elements should suffice: http://jsfiddle.net/Jxzs4/1/
如果我正确理解您的要求,那么只需向右浮动 li 元素就足够了:http: //jsfiddle.net/Jxzs4/1/
回答by Jaiff
<ul style="float:right; text-align:left; list-style:none;">
check this.....
检查这个.....
if you want bullets then remove list-style:none;
如果你想要子弹然后删除 list-style:none;