实例教程 一款纯css3实现的数字统计游戏

所属分类: 网页制作 / CSS 阅读数: 818
收藏 0 赞 0 分享

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

  实现的代码。

  html代码:

XML/HTML Code复制内容到剪贴板
  1. <h1>  
  2.         CSS Counter Game</h1>  
  3.     <section>  
  4.         <h2>  
  5.             Pick the numbers that add up to 72:</h1>  
  6.             <input id="a" type="checkbox"><label for="a">64</label>  
  7.             <input id="b" type="checkbox"><label for="b">16</label>  
  8.             <input id="c" type="checkbox"><label for="c">-32</label>  
  9.             <input id="d" type="checkbox"><label for="d">128</label>  
  10.             <input id="e" type="checkbox"><label for="e">4</label>  
  11.             <input id="f" type="checkbox"><label for="f">-8</label>  
  12.             <span class="sum"></span>  
  13.     </section>  

  css3代码:

CSS Code复制内容到剪贴板
  1. body   
  2.         {   
  3.             countercounter-reset: sum;   
  4.         }   
  5.            
  6.         #a:checked   
  7.         {   
  8.             countercounter-increment: sum 64;   
  9.         }   
  10.         #b:checked   
  11.         {   
  12.             countercounter-increment: sum 16;   
  13.         }   
  14.         #c:checked   
  15.         {   
  16.             countercounter-increment: sum -32;   
  17.         }   
  18.         #d:checked   
  19.         {   
  20.             countercounter-increment: sum 128;   
  21.         }   
  22.         #e:checked   
  23.         {   
  24.             countercounter-increment: sum 4;   
  25.         }   
  26.         #f:checked   
  27.         {   
  28.             countercounter-increment: sum -8;   
  29.         }   
  30.            
  31.         .sum::before   
  32.         {   
  33.             content'= ' counter(sum);   
  34.         }   
  35.            
  36.         /* the rest is just to make things pretty */  
  37.            
  38.         body   
  39.         {   
  40.             margin32px;   
  41.             font: 700 32px/1 'Droid Sans' , sans-serif;   
  42.             color#fff;   
  43.             background-color#583f3f;   
  44.         }   
  45.            
  46.         h1   
  47.         {   
  48.             margin: 0 0 32px;   
  49.             font-size48px;   
  50.         }   
  51.            
  52.         h2   
  53.         {   
  54.             margin: 0 0 8px 8px;   
  55.             font-size: inherit;   
  56.         }   
  57.            
  58.         section   
  59.         {   
  60.             margin-bottom16px;   
  61.             padding16px;   
  62.             border-radius: 4px;   
  63.             overflowhidden;   
  64.             background-color: rgba(255, 255, 255, .1);   
  65.         }   
  66.            
  67.         input   
  68.         {   
  69.             positionabsolute;   
  70.             left: -9999px;   
  71.         }   
  72.            
  73.         label   
  74.         {   
  75.             floatleft;   
  76.             margin8px;   
  77.             padding16px;   
  78.             border-radius: 4px;   
  79.             bordersolid 2px rgba(255, 255, 255, .4);   
  80.             background-color: rgba(255, 255, 255, .2);   
  81.             cursorpointer;   
  82.             transition: all .1s;   
  83.         }   
  84.            
  85.         label::before   
  86.         {   
  87.             displayinline;   
  88.         }   
  89.            
  90.         input:checked + label   
  91.         {   
  92.             bordersolid 2px #fff;   
  93.             background-color: rgba(255, 255, 255, .4);   
  94.             box-shadow: 0 0 10px #fff;   
  95.         }   
  96.            
  97.         span   
  98.         {   
  99.             floatleft;   
  100.             margin8px;   
  101.             padding18px;   
  102.             border-radius: 4px;   
  103.             background-color: rgba(0, 0, 0, .1);   
  104.         }   
  105.            
  106.         #a:checked ~ #b:checked ~ #c:not(:checked) ~ #d:not(:checked) ~ #e:not(:checked) ~ #f:checked ~ .sum::after   
  107.         {   
  108.             content' (hooray!)';   
  109.         }  

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

更多精彩内容其他人还在看

2013年五大主流浏览器 HTML5 与 CSS3 兼容性大比拼

这篇文章主要介绍了2013年五大主流浏览器 HTML5 和 CSS3 兼容性大比拼,需要的朋友可以参考下
收藏 0 赞 0 分享

前端设计师需要了解的9个问题

这篇文章主要介绍了前端设计师需要了解的9个问题以及注意事项,非常的实用,是篇非常不错的文章,这里推荐给大家
收藏 0 赞 0 分享

CSS强制性换行的方法区别详解

自动换行问题,正常字符的换行是比较合理的,而连续的数字和英文字符常常将容器撑大,挺让人头疼,下面介绍的是CSS如何实现换行的方法对于div,p等块级元素正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义的宽度之后自动换行
收藏 0 赞 0 分享

CSS语义化命名方式及常用命名规则

本文搜集了一些CSS语义化命名方式以及命名规则。如有错误或不妥之处,敬请指出,欢迎你提出更好的建议,加插更多的命名规范。
收藏 0 赞 0 分享

ul li内容宽度的问题的解决方案

在IE6下只要我设置LI的宽度为auto,不论LI里面的内容多长,LI的宽度始终是100%,即UL的宽度(这里我已经写死了UL的宽度)。设置max-width也没用。高手们,在IE系列浏览器中如何使LI的宽度真正的随着内容增长而增长呢?像FF那样。
收藏 0 赞 0 分享

html5+css3气泡组件的实现

本文是html5+css3系列教程的第一篇,给大家讲述html5+css3实现气泡组件,讲解的十分的详细,这里推荐给大家,希望对大家能有所帮助
收藏 0 赞 0 分享

html5+css3之CSS中的布局与Header的实现

本文从CSS3的布局(CSS的布局的演化、CSS3盒模型-box-sizing、float布局中的bfc、Flexbox简介)Header布局的实现(float实现布局、Header js的实现)向我们展示了HTML5与CSS3的魅力。
收藏 0 赞 0 分享

一款恶搞头像特效的制作过程 利用css3和jquery

今天给大家介绍一款恶搞头像特效的制作过程,你可以把任意一张照片放到跳舞的漫画中,为他带上不同的帽子,让他翩翩起舞,下面我们一起来看一下制作过程和效果
收藏 0 赞 0 分享

大图片根据分辨率自适应宽度仍居中显示

一个1920*900的大图,在1024*768的分辨率下仍居中显示,如何做到这一点,下面是一个可行的解决方案
收藏 0 赞 0 分享

CSS3提交意见输入框样式代码

这个提交意见输入框,结构使用到了table,样式用的css3,包含了多方面的知识,比较适合新手朋友们
收藏 0 赞 0 分享
查看更多