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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:08:02  来源:igfitidea点击:

CSS right aligned list

htmlcss

提问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: On the right is what I want. On the left is what I have

编辑我附上了一张图片,显示了我想要实现的目标: 右边是我想要的。 左边是我所拥有的

回答by Adriano Repetti

If you need to align the bullets with the text you can use the list-style-positionattribute, 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;