gpt4 book ai didi

CSS : Styling the content of before pseudo element on a list

转载 作者:技术小花猫 更新时间:2023-10-29 10:57:40 25 4
gpt4 key购买 nike

我正在尝试设置有序列表的样式(没有点,带半径的边框并旋转 45°)

<div class="test">
<ol>
<li><span>it's a test</span></li>
<li><span>and again</span></li>
</ol>
</div>

还有CSS

.test ol {
counter-reset: li;
list-style-type: none;
}
.test ol > li {
position:relative;
list-style:none;
}
.test ol > li:before {
content:counter(li);
counter-increment:li;

position:absolute;
top:-2px;
left:-24px;
width:21px;

color:#E2202D;
font-weight:bold;
font-family:"Helvetica Neue", Arial, sans-serif;
text-align:center;
border: 1px dashed #E2202D;
-webkit-border-radius:6px;
border-radius:6px;
-webkit-transform: rotate(45deg);
}

它给我that

这就是我要阻止的地方...如何在不旋转内部数字的情况下旋转边框?如何在 css 中设置伪元素内容的样式?

感谢任何建议:)

最佳答案

无法分别旋转边框和文本。相反,您可以将数字和边框拆分为两个不同的伪元素,:before:after

参见: http://jsbin.com/agotuj/54/edit

.test ol {
counter-reset: li;
list-style-type: none;
}
.test ol > li {
position: relative;
list-style: none;
margin-bottom: 20px;
padding-left: 5px;
}
.test ol > li:before, .test ol > li:after {
position: absolute;
top: -2px;
left: -24px;
width: 21px;
height: 21px;
line-height: 21px;
font-size: 16px;
}
.test ol > li:before {
content: counter(li);
counter-increment: li;
color: #E2202D;
font-weight: bold;
font-family: "Helvetica Neue", Arial, sans-serif;
text-align: center;
}
.test ol > li:after {
content: '';
border: 1px dashed #E2202D;
border-radius: 6px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}

关于CSS : Styling the content of before pseudo element on a list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9226602/

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