Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
n
ff
css
/* ***** Colors - Start ***** */ /* ***** Colors - End ***** */ /* ***** Global Styles - Start ***** */ * { margin: 0; padding: 0; box-sizing: border-box; font-family: "Poppins", sans-serif; } body { background-color: #fdb813; } .container { display: flex; justify-content: center; align-items: center; } /* ***** Global Styles - End ***** */ /* ***** Specific Styles - Start ***** */ .container { height: 100vh; } .switch { width: 60px; height: 110px; padding-top: 2px; background-color: #514e4b; border-radius: 40px; cursor: pointer; outline: none; overflow: hidden; box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); } .toggle-button { transform: scale(0.8); transform-origin: center center; } .toggle { position: relative; width: 35px; height: 35px; margin: 12px; margin-top: 12px; background-color: #fdb813; border-radius: 50%; } .moon-mask { position: absolute; width: 35px; height: 35px; margin: -74px 0 0 34px; background-color: #514e4b; border-radius: 50%; } .circles-wrapper .circle { position: absolute; width: 4px; height: 8px; background-color: #fff; border-radius: 10px; } .circles-wrapper .circle:first-child { margin: -57px 0 0 27px; } .circles-wrapper .circle:nth-child(2) { margin: -9px 0 0 28px; } .circles-wrapper .circle:nth-child(3) { margin: -32px 0 0 51px; transform: rotate(90deg); } .circles-wrapper .circle:nth-child(4) { margin: -33px 0 0 4px; transform: rotate(90deg); } .circles-wrapper .circle:nth-child(5) { margin: -14px 0 0 10px; transform: rotate(45deg); } .circles-wrapper .circle:nth-child(6) { margin: -14px 0 0 45px; transform: rotate(320deg); } .circles-wrapper .circle:nth-child(7) { margin: -50px 0 0 10px; transform: rotate(135deg); } .circles-wrapper .circle:nth-child(8) { margin: -50px 0 0 45px; transform: rotate(235deg); } .text p { margin-left: 5px; font-size: 55px; line-height: 1.1; font-weight: 700; } .social-icons { display: flex; justify-content: space-between; position: fixed; bottom: 20px; right: 20px; width: 70px; } /* ***** Specific Styles - End ***** */
JavaScript
const animate = gsap.timeline({ paused: true }); const animateBackground = new TimelineMax({ paused: true }); let toggle = true; animateBackground .to("body", 0.1, { backgroundImage: "none", backgroundColor: "#111" }, 0.2) .set(".switch", { boxShadow: "0 0 10px rgba(255, 255, 255, 0.2)" }) .to(".text p", 0.1, { color: "#FFF" }, 0.2); animate .to(".toggle-button", 0.2, { scale: 0.7 }, 0) .set(".toggle", { backgroundColor: "#FFF" }) .set(".circle", { display: "none" }) .to(".moon-mask", 0.2, { translateY: 20, translateX: -10 }, 0.2) .to(".toggle-button", 0.2, { translateY: 49 }, 0.2) .to(".toggle-button", 0.2, { scale: 0.9 }) document.getElementsByClassName("switch")[0].addEventListener("click", () => { if(toggle){ animate.restart(); animateBackground.restart(); } else { animate.reverse(); animateBackground.reverse(); } toggle = !toggle; });
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>打开/关闭、开关切换-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号