Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
A
B
C
D
E
F
G
H
I
J
K
L
css
* { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --bg: hsl(223,10%,90%); --fg: hsl(223,10%,10%); --orange: hsl(29,90%,55%); --yellow: hsl(43,90%,55%); --blue: hsl(198,90%,55%); --white: hsl(223,10%,100%); font-size: calc(20px + (30 - 20) * (100vw - 320px) / (1280 - 320)); } body, input { font: 1em/1.5 "Jost", system-ui, -apple-system, sans-serif; } body { background: #282828; color: var(--fg); display: flex; height: 100vh; } form { display: grid; grid-gap: 0 1.5em; grid-template-columns: repeat(2, 1fr); margin: auto; } label { display: block;color: #fff; } .range-pill { --pillWidth: 4.5em; box-shadow: 0 0.375em 0.375em 0 rgba(0, 0, 0, 0.3); display: inline-block; overflow: hidden; position: relative; width: var(--pillWidth); height: 1.5em; } .range-pill, .range-pill:before, .range-pill__input { border-radius: 0.75em; } .range-pill:before, .range-pill:after, .range-pill__fill, .range-pill__input, .range-pill__value { display: block; position: absolute; } .range-pill:before, .range-pill__fill, .range-pill__input, .range-pill__value { top: 0; left: 0; height: 100%; } .range-pill:before, .range-pill__input, .range-pill__value { width: 100%; } .range-pill:before, .range-pill:after { content: ""; z-index: 3; } .range-pill:before { background: radial-gradient(0.5em 0.4em at 0.75em 0.5em, rgba(255, 255, 255, 0.25) 30%, rgba(255, 255, 255, 0) 50%); box-shadow: 0.05em -0.025em 0.25em 0.05em rgba(255, 255, 255, 0.4) inset, 0.125em -0.125em 0.15em 0.25em rgba(255, 255, 255, 0.07) inset, 0 -0.75em 0.175em 0 rgba(0, 0, 0, 0.07) inset, 0 -0.4em 0.05em 0.2em rgba(255, 255, 255, 0.07) inset, 0 -0.125em 0.05em 0.2em rgba(255, 255, 255, 0.1) inset; } .range-pill:after { background: rgba(255, 255, 255, 0.25); border-radius: 0.125em; box-shadow: 0 0 0.1em 0.1em rgba(255, 255, 255, 0.25); top: 0.6em; left: 1.25em; width: calc(var(--pillWidth) - 1.75em); height: 0.1em; } .range-pill--orange-track, .range-pill--orange-thumb .range-pill__fill { background: var(--orange); } .range-pill--yellow-track, .range-pill--yellow-thumb .range-pill__fill { background: var(--yellow); } .range-pill--blue-track, .range-pill--blue-thumb .range-pill__fill { background: var(--blue); } .range-pill--white-track, .range-pill--white-thumb .range-pill__fill { background: var(--white); } .range-pill__fill { box-shadow: 0 0 0.1em #17181c, -0.05em 0 0 rgba(255, 255, 255, 0.3) inset; z-index: 1; } .range-pill__input { background: transparent; cursor: pointer; z-index: 4; -webkit-appearance: none; -moz-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent; } .range-pill__input:focus { outline: transparent; } .range-pill__input:focus-visible { box-shadow: 0 0 0.125em 0.125em #0b46da inset; } .range-pill__input::-moz-focus-outer { border: 0; } .range-pill__input::-webkit-slider-thumb { background: transparent; border: 0; width: 1px; height: 1.5em; -webkit-appearance: none; -moz-appearance: none; appearance: none; } .range-pill__input::-moz-range-thumb { background: transparent; border: 0; width: 1px; height: 1.5em; -webkit-appearance: none; -moz-appearance: none; appearance: none; } .range-pill__value { color: #17181c; font-size: 0.75em; line-height: 2; text-align: center; text-shadow: 0 0 0.2em rgba(23, 24, 28, 0.3), 0.1em 0.1em 0.1em rgba(23, 24, 28, 0.3); z-index: 2; } @media (prefers-color-scheme: dark) { :root { --bg: hsl(223,10%,20%); --fg: hsl(223,10%,90%); } .range-pill { box-shadow: 0 0.375em 0.375em 0 rgba(0, 0, 0, 0.3); } .range-pill:before { background: radial-gradient(0.5em 0.4em at 0.75em 0.5em, rgba(255, 255, 255, 0.2) 30%, rgba(255, 255, 255, 0) 50%); box-shadow: 0.05em -0.025em 0.25em 0.05em rgba(46, 49, 56, 0.4) inset, 0.125em -0.125em 0.15em 0.25em rgba(46, 49, 56, 0.07) inset, 0 -0.75em 0.175em 0 rgba(0, 0, 0, 0.07) inset, 0 -0.4em 0.05em 0.2em rgba(46, 49, 56, 0.07) inset, 0 -0.125em 0.05em 0.2em rgba(46, 49, 56, 0.1) inset; } } @media (min-width: 480px) { form { grid-template-columns: repeat(3, 1fr); } } @media (min-width: 768px) { form { grid-template-columns: repeat(4, 1fr); } }
JavaScript
document.addEventListener("DOMContentLoaded",function(){ let ranges = [ new RangePill("#range1","orange"), new RangePill("#range2","yellow"), new RangePill("#range3","blue"), new RangePill("#range4","white","orange"), new RangePill("#range5","white","yellow"), new RangePill("#range6","white","blue"), new RangePill("#range7","orange","yellow"), new RangePill("#range8","blue","orange"), new RangePill("#range9","yellow","blue"), new RangePill("#range10","yellow","orange"), new RangePill("#range11","orange","blue"), new RangePill("#range12","blue","yellow") ]; }); class RangePill { constructor(qs,thumbColor = "orange",trackColor = "white") { this.el = document.querySelector(qs); this.fill = null; this.value = null; if (this.el) { this.buildSlider(thumbColor,trackColor); this.el.addEventListener("input",this.changeValue.bind(this)); } } buildSlider(thumbColor,trackColor) { this.el.className = "range-pill__input"; // create a div to contain the
let rangeWrap = document.createElement("span"); rangeWrap.className = "range-pill"; // thumb and track colors if (thumbColor) rangeWrap.classList.add(`range-pill--${thumbColor}-thumb`); if (trackColor) rangeWrap.classList.add(`range-pill--${trackColor}-track`); this.el.parentElement.insertBefore(rangeWrap,this.el); // input rangeWrap.appendChild(this.el); // range fill let rangeFill = document.createElement("span"); rangeFill.className = "range-pill__fill"; rangeWrap.appendChild(rangeFill); // range value let rangeValue = document.createElement("span"); rangeValue.className = "range-pill__value"; rangeValue.textContent = this.el.value; rangeWrap.appendChild(rangeValue); // initial value this.fill = rangeFill; this.value = rangeValue; this.changeValue(); } changeValue() { // keep the value within range if (+this.el.value > this.el.max) this.el.value = this.el.max; else if (+this.el.value < this.el.min) this.el.value = this.el.min; // width of fill if (this.fill) { let pct = (this.el.value - this.el.min) / (this.el.max - this.el.min), fillWidth = pct * 100; this.fill.style.width = `${fillWidth}%`; } // value if (this.value) this.value.textContent = this.el.value; } }
粒子
时间
文字
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号