一款純css3實現的數字統計遊戲

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   ar   os   sp   for   

今天給大家分享一款純css3實現的數字統計遊戲。這款遊戲的規則的是將所有的數字相加等於72。這款遊戲的數字按鈕做得很美觀,需要的時候可以借用下。一起看下:

線上預覽   源碼下載

實現的代碼。

html代碼:

 <h1>        CSS Counter Game</h1>    <section>        <h2>            Pick the numbers that add up to 72:</h1>            <input id="a" type="checkbox"><label for="a">64</label>            <input id="b" type="checkbox"><label for="b">16</label>            <input id="c" type="checkbox"><label for="c">-32</label>            <input id="d" type="checkbox"><label for="d">128</label>            <input id="e" type="checkbox"><label for="e">4</label>            <input id="f" type="checkbox"><label for="f">-8</label>            <span class="sum"></span>    </section>

css3代碼:

 body        {            counter-reset: sum;        }                #a:checked        {            counter-increment: sum 64;        }        #b:checked        {            counter-increment: sum 16;        }        #c:checked        {            counter-increment: sum -32;        }        #d:checked        {            counter-increment: sum 128;        }        #e:checked        {            counter-increment: sum 4;        }        #f:checked        {            counter-increment: sum -8;        }                .sum::before        {            content: ‘= ‘ counter(sum);        }                /* the rest is just to make things pretty */                body        {            margin: 32px;            font: 700 32px/1 ‘Droid Sans‘ , sans-serif;            color: #fff;            background-color: #583f3f;        }                h1        {            margin: 0 0 32px;            font-size: 48px;        }                h2        {            margin: 0 0 8px 8px;            font-size: inherit;        }                section        {            margin-bottom: 16px;            padding: 16px;            border-radius: 4px;            overflow: hidden;            background-color: rgba(255, 255, 255, .1);        }                input        {            position: absolute;            left: -9999px;        }                label        {            float: left;            margin: 8px;            padding: 16px;            border-radius: 4px;            border: solid 2px rgba(255, 255, 255, .4);            background-color: rgba(255, 255, 255, .2);            cursor: pointer;            transition: all .1s;        }                label::before        {            display: inline;        }                input:checked + label        {            border: solid 2px #fff;            background-color: rgba(255, 255, 255, .4);            box-shadow: 0 0 10px #fff;        }                span        {            float: left;            margin: 8px;            padding: 18px;            border-radius: 4px;            background-color: rgba(0, 0, 0, .1);        }                #a:checked ~ #b:checked ~ #c:not(:checked) ~ #d:not(:checked) ~ #e:not(:checked) ~ #f:checked ~ .sum::after        {            content: ‘ (hooray!)‘;        }

註:本文愛編程原創文章,轉載請註明原文地址:http://www.w2bc.com/Article/10331

一款純css3實現的數字統計遊戲

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.