gpt4 book ai didi

html - 将没有 class 或 id 的 li 中的文本右对齐

转载 作者:行者123 更新时间:2023-12-02 19:26:09 29 4
gpt4 key购买 nike

我想将文本右侧对齐。但该文本没有任何 id 或类。

.list{list-style:none;}

.list li{padding:10px;border:1px solid black;margin-top:3px;}
.list li a{color:black;}
.list li a:before {
content: "\f00c"; /* FontAwesome Unicode */
font-family: FontAwesome;
display: inline-block;
margin-left: 1px; /* same as padding-left set on li */
margin-right:10px;
}
<ul class="list">
<li class="incomplete"><a href="http://localhost/">First Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Second Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Third Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Fourth Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Fifth Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Sixth Lesson</a> - Not completed</li>
</ul>

我想将未完成文本与右侧对齐。

最佳答案

li 使用 flex 并使用 justify-content:space- Between;

fiddle来玩玩。

.list {
list-style: none;
}

.list li {
padding: 10px;
border: 1px solid black;
margin-top: 3px;
display: flex;
justify-content: space-between;
}

.list li a {
color: black;
}

.list li a:before {
content: "\f00c";
/* FontAwesome Unicode */
font-family: FontAwesome;
display: inline-block;
margin-left: 1px;
/* same as padding-left set on li */
margin-right: 10px;
}
<ul class="list">
<li class="incomplete"><a href="http://localhost/">First Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Second Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Third Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Fourth Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Fifth Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Sixth Lesson</a> - Not completed</li>
</ul>

关于html - 将没有 class 或 id 的 li 中的文本右对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62374608/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com