如何在CSS中设置伪计数器的样式

时间:2014-04-27 16:14:23

标签: html css3 pseudo-element

在此示例中,如何更改计数器的字体大小:

<style>
p
{
counter-increment: myIndex;
}

p:before
{
content:counter(myIndex);
}
</style>

网页内容

<p>First make a variable (myIndex) and make it increase every time a p element occurs.</p>
<p>Then insert the counter in front of all p elements</p>
<p><b>Note:</b> For the counter property to work in IE8, a DOCTYPE must be declared.</p>

http://www.w3schools.com/cssref/tryit.asp?filename=trycss_content_counter

1 个答案:

答案 0 :(得分:1)

只需设置font-size伪造的:before

Demo Fiddle

p {
    counter-increment: myIndex;
}
p:before {
    content:counter(myIndex);
    font-size:30px;
}