Html 如何在中最右侧设置样式<;李>;s

Html 如何在中最右侧设置样式<;李>;s,html,css,Html,Css,无法理解此代码为何不起作用,它仍在左侧: <ul style="list-style: none; width: 200px;" > <li class="item" ><p>hello world</p></li> <li class="item"><p>hello world</p></li> <li class="item"><p>hello world<

无法理解此代码为何不起作用,它仍在左侧:

<ul style="list-style: none; width: 200px;" >
<li class="item" ><p>hello world</p></li>
<li class="item"><p>hello world</p></li>
<li class="item"><p>hello world</p></li>
</ul>

我试着把李的风格转移到p和两者上,但仍然没有效果。帮助?

只需在
上使用
文本对齐:right

  • 你好,世界

  • 你好,世界

  • 你好,世界


.item
属性中添加
文本对齐:right

.item{
位置:相对位置;
边缘顶部:2倍;
文本对齐:右对齐;
}
  • 你好,世界

  • 你好,世界

  • 你好,世界


relative
定位没有多大作用,只需将li标记设置为相对,然后将p标记设置为绝对,现在添加定位,它应该可以工作了。这里不需要
位置:relative
。是的,我知道,但我只添加了
文本对齐:对
代码。不知道我为什么没有考虑文本对齐。很简单。感谢“right:0px;”用于绝对元素,这就是为什么它在您的case@DamienBannerot啊哈,我想在这种情况下,它会对相关元素起作用。
.item {
 position: relative; 
 right: 0px; 
 margin-top: 2px;
}