您好,登錄后才能下訂單哦!
本篇內容主要講解“怎么用純css3實現數字統計游戲”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“怎么用純css3實現數字統計游戲”吧!
今天給大家分享一款純css3實現的數字統計游戲。這款游戲的規則的是將所有的數字相加等于72。這款游戲的數字按鈕做得很美觀,需要的時候可以借用下。一起看下效果圖:
實現的代碼。
html代碼:
XML/HTML Code復制內容到剪貼板
<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復制內容到剪貼板
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實現數字統計游戲”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。