溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Css3如何制作動態(tài)開關(guān)的效果

發(fā)布時間:2022-02-28 10:19:27 來源:億速云 閱讀:154 作者:小新 欄目:web開發(fā)

小編給大家分享一下Css3如何制作動態(tài)開關(guān)的效果,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

<!DOCTYPE html>

<html>

<head>

<title></title>

<style type="text/css">

body{

background: black;

}

* {

margin: 0;

padding: 0;

}

body {

padding: 26%;

}

.button {

display: inline-block;

position: relative;

height: 40px;

-webkit-user-select: none;

-webkit-tap-highlight-color: rgba(0, 0, 0, 0);

cursor: pointer;

background-color: #eee;

border-radius: 30px;

}

input {

opacity: 0;

position: absolute;

top: 0;

left: 0;

}

.button:before {

content: "";

display: inline-block;

width: 80px;

height: 42px;

background-color: #fff;

border-radius: 42px;

box-sizing: border-box;

border: 2px solid #eee;

transition: all 0.2s linear;

}

.button:after {

position: absolute;

left: 2px;

top: 2px;

content: "";

display: inline-block;

width: 38px;

height: 38px;

background-color: #fff;

border-radius: 40px;

transition: all 0.2s linear;

box-shadow: 0px 1px 3px #bbb;

}

input:checked ~ .button:before {

background-color: red;

border: 1px solid red;

}

input:checked ~ .button:after {

left: 40px;

}

</style>

</head>

<body>

<input type="checkbox" id="swtich">

<label class="button" for="swtich"></label>

</body>

</html><!DOCTYPE html>

<html>

<head>

<title></title>

<style type="text/css">

body{

background: black;

}

* {

margin: 0;

padding: 0;

}

body {

padding: 26%;

}

.button {

display: inline-block;

position: relative;

height: 40px;

-webkit-user-select: none;

-webkit-tap-highlight-color: rgba(0, 0, 0, 0);

cursor: pointer;

background-color: #eee;

border-radius: 30px;

}

input {

opacity: 0;

position: absolute;

top: 0;

left: 0;

}

.button:before {

content: "";

display: inline-block;

width: 80px;

height: 42px;

background-color: #fff;

border-radius: 42px;

box-sizing: border-box;

border: 2px solid #eee;

transition: all 0.2s linear;

}

.button:after {

position: absolute;

left: 2px;

top: 2px;

content: "";

display: inline-block;

width: 38px;

height: 38px;

background-color: #fff;

border-radius: 40px;

transition: all 0.2s linear;

box-shadow: 0px 1px 3px #bbb;

}

input:checked ~ .button:before {

background-color: red;

border: 1px solid red;

}

input:checked ~ .button:after {

left: 40px;

}

</style>

</head>

<body>

<input type="checkbox" id="swtich">

<label class="button" for="swtich"></label>

</body>

</html>

以上是“Css3如何制作動態(tài)開關(guān)的效果”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI