Implementation of counters in css-notes and css counters
Reference http://mp.weixin.qq.com/s? _ Biz = MzU3MDA0NTMzMA ==& mid = 2247485533 & amp; idx = 1 & amp; sn = e88dc5fffa60aeec13b341c1b90954dd & source = 41 # wechat_redirect
Knowledge Used
Pseudo class
Counter-reset attribute, set the incremental start
Counter-increment attribute, set the Incremental Value
Content attribute calculation Increment
Counter Function
The code format is as follows. Note the following:
<! -- Count every ul from 1 and display numbers -->
<! -- Each li starts counting from 1 in ul -->
<Ul class = "box"> Title 1
<Li> content 1 </li>
<Li> content 2 </li>
<Li> content 3 </li>
<Li> content 4 </li>
</Ul>
<Ul class = "box"> Title 2
<Li> content 1 </li>
<Li> content 2 </li>
<Li> content 3 </li>
<Li> content 4 </li>
</Ul>
<Ul class = "box"> Title 3
<Li> content 1 </li>
<Li> content 2 </li>
<Li> content 3 </li>
<Li> content 4 </li>
</Ul>
<Style>
Body {
/* The name can be customized, but it must be defined on the parent container of the container you want to count */
Counter-reset: startVal;
}
Ul {
/* Name */
Counter-reset: contentCounter;
}
/* Use the pseudo class in css */
Ul: before {
/* Defines the increment. The first parameter is the start value, and the second parameter is the increment value, either positive or negative */
Counter-increment: startVal 3;
/* Here is the counting function. The first parameter is the start value, and the second parameter is the display style. The specific parameters are not listed. The smart prompt is displayed */
Content: 'The title is displayed here -- 'counter (startVal );
}
Li: before {
Counter-increment: contentCounter;
Content: 'content list -- 'counter (contentCounter );
}
</Style>