gpt4 book ai didi

css - 带箭头的样式元素符号列表

转载 作者:技术小花猫 更新时间:2023-10-29 11:18:43 26 4
gpt4 key购买 nike

我创建了一个箭头,我想将其附加到列表而不是圆形元素符号点。我尝试使用 :after 但还没有成功,不得不承认我对伪元素非常陌生......

这是我到目前为止得到的:

#arrow {
border-right:2px solid black;
border-bottom:2px solid black;
width:10px;
height:10px;
transform: rotate(-45deg);
margin-top:40px;
}



ul li {
padding-bottom: 10px;
}

ul li:before{
border-right:5px solid black;
border-bottom:5px solid black;
width:10px;
height:10px;
transform: rotate(-45deg);
margin-top:40px;
}
<!-- Arrow below -->
<div id="arrow"></div>


<!-- Want to place arrow where bullet points are -->
<ul>
<li>Item #1</li>
<li>Item #2</li>
<li>Item #3</li>
<li>Item #4</li>
<li>Item #5</li>
</ul>

有人有什么想法吗?

最佳答案

content: '' 与伪元素(:before:after)一起使用。并使用 list-style: noneul 删除元素符号。喜欢:

ul {
list-style: none;
}

ul li:before{
content: '';
position: absolute;
border-right:2px solid black;
border-bottom:2px solid black;
width:10px;
height:10px;
top: calc(50% - 4px);
left: -20px;
transform: translateY(-50%) rotate(-45deg);
}

看看下面的片段:

#arrow {
border-right:2px solid black;
border-bottom:2px solid black;
width:10px;
height:10px;
transform: rotate(-45deg);
margin-top:40px;
}



ul li {
position: relative;
padding-bottom: 10px;
}

ul {
list-style: none;
}

ul li:before{
content: '';
position: absolute;
border-right:2px solid black;
border-bottom:2px solid black;
width:10px;
height:10px;
top: calc(50% - 4px);
left: -20px;
transform: translateY(-50%) rotate(-45deg);
}
<!-- Want to place arrow where bullet points are  -->
<ul>
<li>Item #1</li>
<li>Item #2</li>
<li>Item #3</li>
<li>Item #4</li>
<li>Item #5</li>
</ul>

希望这对您有所帮助!

关于css - 带箭头的样式元素符号列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46802769/

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