我正在使用css中的自定义计数器进行打印。但是,当h1标记位于自定义组件内时,计数器似乎会重置。这是一个bug吗?
示例: css:
h1 {
counter-increment: countH1;
}
html:
<h1>hello</h1> -> counter is 1
<h1>hello</h1> -> counter is 2
<my-component>
<h1>hello again</h1> -> counter is 1 again :-(
</my-component>
请注意,my-component是一个自定义元素。这是一个组件(‘my-customElements.define’,myComponent);在JS中的实现。
css计数器与自定义组件不兼容吗?
约翰。
发布于 2018-07-25 08:53:57
你可以让你的超文本标记语言保持原样,但是试着在之前或之后使用CSS:,让你的CSS看起来有点像这样。
body {
counter-reset: countH1;
}
h1 {
counter-increment: countMe;
}
h1:before {
content: counter(countMe, upper-roman);
padding-right: 20px;
}
https://stackoverflow.com/questions/51509034
复制相似问题