Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
SVG toggle animation
A full css/svg checkbox button
css
body { background-color: #eee; padding-top: 40px; } h1 { text-align: center; font-size: 20px; text-transform: uppercase; letter-spacing: 1.2px; } h2 { text-align: center; font-size: 14px; text-transform: uppercase; letter-spacing: 1.2px; } hr { margin: 0 auto; margin-top: 50px; margin-bottom: 50px; } footer { text-align: center; padding-bottom: 50px; } .link { text-align: center; color: #278fb2; } .checkbox { width: 200px; margin: 0 auto; } .checkbox__container { display: block; position: relative; height: 82px; } .checkbox__toggle { display: none; } .checkbox__toggle:checked ~ .checkbox__path .path--top { stroke-dashoffset: 0px; stroke: #0cb018; } .checkbox__toggle:checked ~ .checkbox__path .path--bottom { stroke-dasharray: 14px 360px; stroke-dashoffset: 0px; stroke: #0cb018; } .checkbox__checker { position: absolute; top: 4px; left: 4px; z-index: 1; display: block; width: 73px; height: 73px; background-color: #fff; border-radius: 50%; z-index: 9; } .checkbox__bg, .checkbox__path { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .checkbox__bg .shape-bg { fill: #aaa; } .checkbox__path { z-index: 9; } .checkbox__path .shape-bg { fill: #fff; stroke-width: 1px; stroke: #aaa; } .checkbox__path .path { stroke-width: 4px; stroke: #bf1e1e; fill: none; stroke-linecap: round; transition: 1s; } .checkbox__path .path--top { stroke-dasharray: 33px 360px; stroke-dashoffset: -336px; } .checkbox__path .path--bottom { stroke-dasharray: 33px 360px; stroke-dashoffset: -324px; } .checkbox #checkbox__circle { z-index: 9; position: absolute; top: 0; left: 0; width: 100%; height: 100%; fill: #fff; } .anim { transition-timing-function: cubic-bezier(0.385, -0.6, 0.685, 1.59); transition-duration: .2s; } .anim--go-right { left: calc(100% - 76px); } .anim--speed { -webkit-animation-duration: .5s; animation-duration: .5s; -webkit-animation-name: speedSmall; animation-name: speedSmall; } @-webkit-keyframes speed { 0% { -webkit-transform: scaleY(0.6); transform: scaleY(0.6); } 30% { -webkit-transform: scaleY(2.3); transform: scaleY(2.3); } 60% { -webkit-transform: scaleY(2.3); transform: scaleY(2.3); } 100% { -webkit-transform: scaleY(0.6); transform: scaleY(0.6); } } @keyframes speed { 0% { -webkit-transform: scaleY(0.6); transform: scaleY(0.6); } 30% { -webkit-transform: scaleY(2.3); transform: scaleY(2.3); } 60% { -webkit-transform: scaleY(2.3); transform: scaleY(2.3); } 100% { -webkit-transform: scaleY(0.6); transform: scaleY(0.6); } } @-webkit-keyframes speedSmall { 0% { -webkit-transform: scale(1, 1); transform: scale(1, 1); } 25% { -webkit-transform: scale(0.7, 0.7); transform: scale(0.7, 0.7); } 35% { -webkit-transform: scale(0.7, 0.7); transform: scale(0.7, 0.7); } 50% { -webkit-transform: scale(0.7, 0.3); transform: scale(0.7, 0.3); } 65% { -webkit-transform: scale(0.7, 0.7); transform: scale(0.7, 0.7); } 75% { -webkit-transform: scale(0.7, 0.7); transform: scale(0.7, 0.7); } 100% { -webkit-transform: scale(1, 1); transform: scale(1, 1); } } @keyframes speedSmall { 0% { -webkit-transform: scale(1, 1); transform: scale(1, 1); } 25% { -webkit-transform: scale(0.7, 0.7); transform: scale(0.7, 0.7); } 35% { -webkit-transform: scale(0.7, 0.7); transform: scale(0.7, 0.7); } 50% { -webkit-transform: scale(0.7, 0.3); transform: scale(0.7, 0.3); } 65% { -webkit-transform: scale(0.7, 0.7); transform: scale(0.7, 0.7); } 75% { -webkit-transform: scale(0.7, 0.7); transform: scale(0.7, 0.7); } 100% { -webkit-transform: scale(1, 1); transform: scale(1, 1); } }
JavaScript
var toggler = $('.checkbox__toggle'); var circle = $('.checkbox__checker'); var time1 = 150; var time2 = 800; toggler.click(function(){ circle.removeClass('anim--speed'); if($(this).is(":checked")){ setTimeout(function(){ circle.addClass('anim--speed'); },10); setTimeout(function(){ circle.addClass('anim--go-right'); },time1); } else{ setTimeout(function(){ circle.addClass('anim--speed'); },10); setTimeout(function(){ circle.removeClass('anim--go-right'); },time1); } })
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>SVG CSS复选框-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号