CSS3制作动态左右开关,动态开关按钮是一款非常酷的CSS3的开关按钮,点击按钮可以左右滑动,就像开关打开闭合一样的效果,通过本篇文章给大家介绍纯CSS3代码实现滑动开关效果,需要的朋友可以参考下
<!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 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 for="swtich"></label> </body> </html>
相信看了这些案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
相关阅读:
以上是Css3制作动态开关的效果的实现步骤的详细内容。更多信息请关注PHP中文网其他相关文章!

具有CSS的自定义光标很棒,但是我们可以将JavaScript提升到一个新的水平。使用JavaScript,我们可以在光标状态之间过渡,将动态文本放置在光标中,应用复杂的动画并应用过滤器。

互动CSS动画和元素相互启动的元素在2025年似乎更合理。虽然不需要在CSS中实施乒乓球,但CSS的灵活性和力量的增加,可以怀疑Lee&Aver Lee&Aver Lee有一天将是一场

有关利用CSS背景滤波器属性来样式用户界面的提示和技巧。您将学习如何在多个元素之间进行背景过滤器,并将它们与其他CSS图形效果集成在一起以创建精心设计的设计。

好吧,事实证明,SVG的内置动画功能从未按计划进行弃用。当然,CSS和JavaScript具有承载负载的能力,但是很高兴知道Smil并没有像以前那样死在水中

是的,让#039;跳上文字包装:Safari Technology Preview In Pretty Landing!但是请注意,它与在铬浏览器中的工作方式不同。

此CSS-tricks更新了,重点介绍了年鉴,最近的播客出现,新的CSS计数器指南以及增加了几位新作者,这些新作者贡献了有价值的内容。

在大多数情况下,人们展示了@Apply的@Apply功能,其中包括Tailwind的单个property实用程序之一(会改变单个CSS声明)。当以这种方式展示时,@Apply听起来似乎很有希望。如此明显


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

SublimeText3 英文版
推荐:为Win版本,支持代码提示!