CSS如何實(shí)現(xiàn)手機(jī)中開(kāi)關(guān)的實(shí)例分析
來(lái)源:懂視網(wǎng)
責(zé)編:小采
時(shí)間:2020-11-27 18:50:00
CSS如何實(shí)現(xiàn)手機(jī)中開(kāi)關(guān)的實(shí)例分析
CSS如何實(shí)現(xiàn)手機(jī)中開(kāi)關(guān)的實(shí)例分析:在很多設(shè)計(jì)圖上,會(huì)有如下圖開(kāi)關(guān)或者單選,今天我就來(lái)講講如何用css去實(shí)現(xiàn)動(dòng)態(tài)的開(kāi)關(guān)。html代碼中,是很簡(jiǎn)單的<input type="checkbox" id="1" class="checkbox"> <label class=&
導(dǎo)讀CSS如何實(shí)現(xiàn)手機(jī)中開(kāi)關(guān)的實(shí)例分析:在很多設(shè)計(jì)圖上,會(huì)有如下圖開(kāi)關(guān)或者單選,今天我就來(lái)講講如何用css去實(shí)現(xiàn)動(dòng)態(tài)的開(kāi)關(guān)。html代碼中,是很簡(jiǎn)單的<input type="checkbox" id="1" class="checkbox"> <label class=&
在很多設(shè)計(jì)圖上,會(huì)有如下圖開(kāi)關(guān)或者單選,今天我就來(lái)講講如何用css去實(shí)現(xiàn)動(dòng)態(tài)的開(kāi)關(guān)。

html代碼中,是很簡(jiǎn)單的
<input type="checkbox" id="1" class="checkbox">
<label class="switch" for="1"></label>
下面是我們css代碼
<style>
.checkbox {
display: none;
}
.switch {
width: 50px;
height: 31px;
background: #56ACFE;
border-radius: 20px;
padding: 1px;
box-sizing: border-box;
display: inline-block;
margin-top: 15px;
}
.switch:after {
content: '';
box-shadow: 0 3px 8px 0 rgba(0,0,0,0.15), 0 1px 1px 0 rgba(0,0,0,0.16), 0 3px 1px 0 rgba(0,0,0,0.10);
width: 28px;
height: 28px;
background: #fff;
border-radius: 50%;
display: block;
margin-left: 1px;
float: left;
transition: all 0.5s;
}
.checkbox:checked+.switch:after {
margin-left: 20px;
}
.checkbox:checked+.switch {
background: #ccc;
}
</style>
就這樣,就實(shí)現(xiàn)了這個(gè)設(shè)計(jì)圖上和手機(jī)上經(jīng)常出現(xiàn)的開(kāi)關(guān)。
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
CSS如何實(shí)現(xiàn)手機(jī)中開(kāi)關(guān)的實(shí)例分析
CSS如何實(shí)現(xiàn)手機(jī)中開(kāi)關(guān)的實(shí)例分析:在很多設(shè)計(jì)圖上,會(huì)有如下圖開(kāi)關(guān)或者單選,今天我就來(lái)講講如何用css去實(shí)現(xiàn)動(dòng)態(tài)的開(kāi)關(guān)。html代碼中,是很簡(jiǎn)單的<input type="checkbox" id="1" class="checkbox"> <label class=&