实例好代码教程 一款纯css3如何实现的数字统计游戏

房子修得再大也是临时住所,只有那个小木匣才是永久的家,所以,屋宽不如心宽,身安不如心安!

  今天给大家分享一款纯css3实现的数字统计游戏。这款游戏的规则的是将所有的数字相加等于72。这款游戏的数字按钮做得很美观,需要的时候可以借用下。一起看下效果图:

  实现的代码。

  html代码:

XML/HTML Code复制内容到剪贴板
  1. <h1>
  2. CSSCounterGame</h1>
  3. <section>
  4. <h2>
  5. Pickthenumbersthataddupto72:</h1>
  6. <inputid="a"type="checkbox"><labelfor="a">64</label>
  7. <inputid="b"type="checkbox"><labelfor="b">16</label>
  8. <inputid="c"type="checkbox"><labelfor="c">-32</label>
  9. <inputid="d"type="checkbox"><labelfor="d">128</label>
  10. <inputid="e"type="checkbox"><labelfor="e">4</label>
  11. <inputid="f"type="checkbox"><labelfor="f">-8</label>
  12. <spanclass="sum"></span>
  13. </section>

  css3代码:

CSS Code复制内容到剪贴板
  1. body
  2. {
  3. countercounter-reset:sum;
  4. }
  5. #a:checked
  6. {
  7. countercounter-increment:sum64;
  8. }
  9. #b:checked
  10. {
  11. countercounter-increment:sum16;
  12. }
  13. #c:checked
  14. {
  15. countercounter-increment:sum-32;
  16. }
  17. #d:checked
  18. {
  19. countercounter-increment:sum128;
  20. }
  21. #e:checked
  22. {
  23. countercounter-increment:sum4;
  24. }
  25. #f:checked
  26. {
  27. countercounter-increment:sum-8;
  28. }
  29. .sum::before
  30. {
  31. content:'='counter(sum);
  32. }
  33. /*therestisjusttomakethingspretty*/
  34. body
  35. {
  36. margin:32px;
  37. font:70032px/1'DroidSans',sans-serif;
  38. color:#fff;
  39. background-color:#583f3f;
  40. }
  41. h1
  42. {
  43. margin:0032px;
  44. font-size:48px;
  45. }
  46. h2
  47. {
  48. margin:008px8px;
  49. font-size:inherit;
  50. }
  51. section
  52. {
  53. margin-bottom:16px;
  54. padding:16px;
  55. border-radius:4px;
  56. overflow:hidden;
  57. background-color:rgba(255,255,255,.1);
  58. }
  59. input
  60. {
  61. position:absolute;
  62. left:-9999px;
  63. }
  64. label
  65. {
  66. float:left;
  67. margin:8px;
  68. padding:16px;
  69. border-radius:4px;
  70. border:solid2pxrgba(255,255,255,.4);
  71. background-color:rgba(255,255,255,.2);
  72. cursor:pointer;
  73. transition:all.1s;
  74. }
  75. label::before
  76. {
  77. display:inline;
  78. }
  79. input:checked+label
  80. {
  81. border:solid2px#fff;
  82. background-color:rgba(255,255,255,.4);
  83. box-shadow:0010px#fff;
  84. }
  85. span
  86. {
  87. float:left;
  88. margin:8px;
  89. padding:18px;
  90. border-radius:4px;
  91. background-color:rgba(0,0,0,.1);
  92. }
  93. #a:checked~#b:checked~#c:not(:checked)~#d:not(:checked)~#e:not(:checked)~#f:checked~.sum::after
  94. {
  95. content:'(hooray!)';
  96. }

  以上就是css3实现的数字统计游戏的代码,自己做一下玩是不是更有意思,谢谢阅读,希望能帮到大家,请继续关注,我们会努力分享更多优秀的文章。

您可能有感兴趣的文章
css让页脚保持在底部位置的四种方案

CSS如何使用Flex和Grid布局如何实现3D骰子

Flex布局史上最简单使用语法教程

新的CSS 伪类函数 :is() 和 :where()示例详解

纯CSS打字动画的如何实现示例