如何修改以下代码,使H2标题前的橙色框中的数字可以显示为数字1,2,3...?
示例网站文章:https://weblai.co/css-title/
代码如下:
add_action('wp_head',function(){ ?>
<style>
@import url('https://fonts.googleapis.com/css?family=Noto+Sans+TC');
body {font-family: 'Noto Sans TC', sans-serif;}/*思源黑體*/
article .ast-post-format- .entry-content h2:before {
content: counter(chapter) "";
color: #fff;
background-image: linear-gradient(45deg, #805300 0%, #805300 1%, #F59F00 100%);
box-shadow: 0 1px 4px rgba(0,0,0,0.3);
border-radius: 3px;
padding: 0 0.8rem;
margin: 0 0.8rem 0 0;
}发布于 2021-01-14 07:41:08
看起来你正在使用计数器(章节)而没有初始化它。
在正文规则前添加以下内容:
body {
counter-reset: chapter; /* Set a counter named 'section', and its initial value is 0. */
}来源:
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Lists_and_Counters/Using_CSS_counters
https://stackoverflow.com/questions/65707972
复制相似问题