Css3如何制作动态开关的效果


小编给大家分享一下Css3如何制作动态开关的效果,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

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;

}

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 {

c免费云主机域名ontent: “”;

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;

}

以上是“Css3如何制作动态开关的效果”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注百云主机行业资讯频道!

相关推荐: JavaScript如何创建一个自调用函数

这篇文章主要介绍JavaScript如何创建一个自调用函数,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!这个经常被称为自调用匿名函数(Self-Invoked Anonymous Function)或者即时调用函数表达式(IIFE-Im…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 09/07 22:33
下一篇 09/07 22:33

相关推荐