html - ol 项目符号类型和文本 css
问题描述
我有这个 css 的 ol:
ol {
list-style-type: upper-roman;
color: red;
}
我的问题是……我的 li 和其中的任何文本都是红色的。
<li>Some Text</li>
如果我做:
<li><span>Some Text</span></li>
我可以随心所欲地操纵跨度没问题,但是......有没有一种CSS方法来改变文本颜色而不包含在一个单独的元素中?
感谢您的建议:)
解决方案
您可以使用counters
如下
ol {
counter-reset: section;
list-style: none;
}
li::before {
color: red;
content: counter(section, upper-roman);
margin-right: 5px;
}
li {
counter-increment: section;
}
<ol>
<li>Some text</li>
<li>Some text</li>
</ol>
推荐阅读
- jolt - 使用 JOLT 将 json 数组中的值转换为另一个值
- vue.js - 为什么子组件的 v-model 不会从发射更改为父组件?
- r - 更改子图中的 y 限制
- python - 创建基于另一个列值增加计数的 Dataframe 列
- html - HTML CSS 框动画
- r - 将 stat_pvalue_manual 与 fill = GROUP 结合
- android - 列表视图自定义适配器不起作用,当我打开 Activity 时没有显示
- html - 防止字符串在表格标签内不中断
- python - 熊猫按列规范化行
- python - 将字符串数组从 python 传递到 C 并在 for 循环中使用(包括代码)