Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Android
Linux
macOS
Windows
css
* { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --bg: #e3e4e8; --bgT: #e3e4e800; --fg: #17181c; --focused: #b6cafb; --focusRing: #86a6f9; --unchecked: #ffffff; --checked: #255ff4; font-size: calc(20px + (30 - 20) * (100vw - 320px) / (1280 - 320)); } body, input { font: 1em/1.5 system-ui, -apple-system, sans-serif; } body { background: #f6fddb; color: var(--fg); display: flex; height: 100vh; } form { margin: auto; overflow: hidden; position: relative; padding: 0.75em 0; } form:before, form:after, .circles, .circle { position: absolute; } form:before, form:after { content: ""; left: 0; width: 100%; height: 0.5em; z-index: 1; } form:before { top: 0; } form:after { bottom: 0; } input { position: fixed; top: -1.5em; left: -1.5em; } input:checked + label { background: var(--focused); box-shadow: 0 0 0 2px var(--focusRing) inset; } input:nth-of-type(2):checked ~ .circles .circle { transform: translateY(-6em); } input:nth-of-type(3):checked ~ .circles .circle { transform: translateY(-3em); } input:nth-of-type(4):checked ~ .circles .circle { transform: translateY(0); } label, .circle { transition: all 0.25s ease-in-out; } label { border-radius: 0.25em; cursor: pointer; display: block; padding: 0.75em 1em 0.75em 2.75em; -tap-highlight-color: transparent; } .circles { padding: 0.25em 0; top: 0; left: 1em; } .circle { background: var(--unchecked); border-radius: 50%; box-shadow: -0.2em -0.2em 0.2em #0003 inset, 0.2em 0.2em 0.2em #0003; pointer-events: none; top: 1.75em; transform: translateY(-9em); width: 1em; height: 1em; } .circle:nth-child(2) { top: 4.75em; transition-delay: 0.05s; } .circle:nth-child(3) { top: 7.75em; transition-delay: 0.1s; } .circle:nth-child(4) { top: 10.75em; transition-delay: 0.15s; } .circle:nth-child(5) { top: 13.75em; transition-delay: 0.2s; } .circle:nth-child(6) { top: 16.75em; transition-delay: 0.25s; } .circle:nth-child(7) { top: 19.75em; transition-delay: 0.3s; } .circle-checked { background: var(--checked); } .circles-flip-delays .circle:nth-child(1) { transition-delay: 0.3s; } .circles-flip-delays .circle:nth-child(2) { transition-delay: 0.25s; } .circles-flip-delays .circle:nth-child(3) { transition-delay: 0.2s; } .circles-flip-delays .circle:nth-child(4) { transition-delay: 0.15s; } .circles-flip-delays .circle:nth-child(5) { transition-delay: 0.1s; } .circles-flip-delays .circle:nth-child(6) { transition-delay: 0.05s; } .circles-flip-delays .circle:nth-child(7) { transition-delay: 0s; } /* Dark mode */ @media (prefers-color-scheme: dark) { :root { --bg: #17181c; --bgT: #17181c00; --fg: #e3e4e8; --focused: #062779; --focusRing: #0936aa; --unchecked: #5c6270; } }
JavaScript
document.addEventListener("DOMContentLoaded",() => { let os = new RollingRadios("os"); }); class RollingRadios { constructor(radioName) { this.circles = document.querySelector(".circles"); this.data_attr = "data-radio-index"; this.last_focused_index = 0; this.radio_name = radioName; this.first_focused_index(); document.addEventListener("change",this.update_last_focused_index.bind(this)); } first_focused_index() { let radios = document.getElementsByName(this.radio_name); radios.forEach(r => { if (r.checked) this.update_last_focused_index(r); }); } flip_delays(radioIndex) { // flip the delays depending on which index is greater if (this.circles) { let lfi = this.last_focused_index, flipClass = "circles-flip-delays"; if (radioIndex > lfi) this.circles.classList.add(flipClass); else if (radioIndex < lfi) this.circles.classList.remove(flipClass); } } update_last_focused_index(e) { let tar = e.target || e, radioIndex = tar.getAttribute(this.data_attr); if (tar.name == this.radio_name && radioIndex) { this.flip_delays(radioIndex); this.last_focused_index = radioIndex; } } }
粒子
时间
文字
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号