时间:2021-07-01 10:21:17 帮助过:72人阅读
counter-increment:设置某个选取器每次出现的计数器增量。默认增量是 1。
demo
css 实现计数和
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>
更多css计数器相关文章请关注PHP中文网!