您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“怎么用純css3實(shí)現(xiàn)數(shù)字統(tǒng)計游戲”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“怎么用純css3實(shí)現(xiàn)數(shù)字統(tǒng)計游戲”吧!
今天給大家分享一款純css3實(shí)現(xiàn)的數(shù)字統(tǒng)計游戲。這款游戲的規(guī)則的是將所有的數(shù)字相加等于72。這款游戲的數(shù)字按鈕做得很美觀,需要的時候可以借用下。一起看下效果圖:
實(shí)現(xiàn)的代碼。
html代碼:
XML/HTML Code復(fù)制內(nèi)容到剪貼板
<h2>
CSS Counter Game</h2>
<section>
<h3>
Pick the numbers that add up to 72:</h2>
<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代碼:
CSS Code復(fù)制內(nèi)容到剪貼板
body
{
countercounter-reset: sum;
}
#a:checked
{
countercounter-increment: sum 64;
}
#b:checked
{
countercounter-increment: sum 16;
}
#c:checked
{
countercounter-increment: sum -32;
}
#d:checked
{
countercounter-increment: sum 128;
}
#e:checked
{
countercounter-increment: sum 4;
}
#f:checked
{
countercounter-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;
}
h2
{
margin: 0 0 32px;
font-size: 48px;
}
h3
{
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!)';
}
到此,相信大家對“怎么用純css3實(shí)現(xiàn)數(shù)字統(tǒng)計游戲”有了更深的了解,不妨來實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。