Home >Web Front-end >CSS Tutorial >css counter
css counter is css3, only effective in modern browsers
counter-reset: Set the value of the counter for the number of occurrences of a certain selector. Default is 0. Just define a counter, you can define the initial value, the default is 0
counter-increment: Set the counter increment each time a selector appears. The default increment is 1.
demo
#css implements counting and
css
body{ margin: 0; counter-reset: increment; } input{ border: none; margin: 0; padding: 0; } .number1 input[type=checkbox]:checked{ counter-increment:increment 20; } .number2 input[type=checkbox]:checked{ counter-increment:increment 30; } .number3 input[type=checkbox]:checked{ counter-increment:increment 40; } .number4 input[type=checkbox]:checked{ counter-increment:increment 50; } .number5 input[type=checkbox]:checked{ counter-increment:increment 60; } .sum:after{ content: counter(increment); }
html
<label class="number1"><input type="checkbox">20</label>+<label class="number2"><input type="checkbox">30</label>+<label class="number3"><input type="checkbox">40</label>+<label class="number4"><input type="checkbox">50</label>+<label class="number5"><input type="checkbox">60</label>=<p class="sum"></p>
For more articles related to css counter, please pay attention to the PHP Chinese website!