CSS:设置列表上伪元素之前的内容样式
我正在尝试设计一个有序列表的样式(没有点,带有半径的边框并旋转 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);
}
它给了我 那个< /a>
这就是我阻塞的地方...如何旋转边框而不旋转里面的数字?如何在 css 中设置伪元素内容的样式?
感谢您的任何建议:)
I'm trying to style an ordered list (no dot, a border with radius and rotate 45°)
<div class="test">
<ol>
<li><span>it's a test</span></li>
<li><span>and again</span></li>
</ol>
</div>
And the 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);
}
It give me that
And this is here i'm blocking... How to rotate the border without rotate the number inside ? How to style the content of a pseudo element in css ?
Thanks for any advice :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无法单独旋转边框和文本。相反,您可以将数字和边框拆分为两个不同的伪元素:
:before
和:after
。参见: http://jsbin.com/agotuj/54/edit
There's no way to rotate the border and text separately. Instead, you can split the number and the border into two different pseudo-elements,
:before
and:after
.See: http://jsbin.com/agotuj/54/edit