Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body, html { background-color: #1d1c25; margin: 0; padding: 0; } .range { -webkit-appearance: none; -moz-appearance: none; position: absolute; left: 50%; top: 50%; width: 200px; margin-top: 10px; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } input[type=range]::-webkit-slider-runnable-track { -webkit-appearance: none; background: rgba(59,173,227,1); background: -webkit-gradient(left bottom, right top, color-stop(0%, rgba(59,173,227,1)), color-stop(25%, rgba(87,111,230,1)), color-stop(51%, rgba(152,68,183,1)), color-stop(100%, rgba(255,53,127,1))); background: linear-gradient(45deg, rgba(59,173,227,1) 0%, rgba(87,111,230,1) 25%, rgba(152,68,183,1) 51%, rgba(255,53,127,1) 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3bade3 ', endColorstr='#ff357f ', GradientType=1 ); height: 2px; } input[type=range]:focus { outline: none; } input[type=range]::-moz-range-track { -moz-appearance: none; background: rgba(59,173,227,1); background: -webkit-gradient(left bottom, right top, color-stop(0%, rgba(59,173,227,1)), color-stop(25%, rgba(87,111,230,1)), color-stop(51%, rgba(152,68,183,1)), color-stop(100%, rgba(255,53,127,1))); background: linear-gradient(45deg, rgba(59,173,227,1) 0%, rgba(87,111,230,1) 25%, rgba(152,68,183,1) 51%, rgba(255,53,127,1) 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3bade3 ', endColorstr='#ff357f ', GradientType=1 ); height: 2px; } input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; border: 2px solid; border-radius: 50%; height: 25px; width: 25px; max-width: 80px; position: relative; bottom: 11px; background-color: #1d1c25; cursor: -webkit-grab; -webkit-transition: border 1000ms ease; transition: border 1000ms ease; } input[type=range]::-moz-range-thumb { -moz-appearance: none; border: 2px solid; border-radius: 50%; height: 25px; width: 25px; max-width: 80px; position: relative; bottom: 11px; background-color: #1d1c25; cursor: -moz-grab; -webkit-transition: border 1000ms ease; transition: border 1000ms ease; } .range.blue::-webkit-slider-thumb { border-color: rgb(59,173,227); } .range.ltpurple::-webkit-slider-thumb { border-color: rgb(87,111,230); } .range.purple::-webkit-slider-thumb { border-color: rgb(152,68,183); } .range.pink::-webkit-slider-thumb { border-color: rgb(255,53,127); } .range.blue::-moz-range-thumb { border-color: rgb(59,173,227); } .range.ltpurple::-moz-range-thumb { border-color: rgb(87,111,230); } .range.purple::-moz-range-thumb { border-color: rgb(152,68,183); } .range.pink::-moz-range-thumb { border-color: rgb(255,53,127); } input[type=range]::-webkit-slider-thumb:active { cursor: -webkit-grabbing; } input[type=range]::-moz-range-thumb:active { cursor: -moz-grabbing; }
JavaScript
var inputRange = document.getElementsByClassName('range')[0], maxValue = 100, // the higher the smoother when dragging speed = 5, currValue, rafID; // set min/max value inputRange.min = 0; inputRange.max = maxValue; // listen for unlock function unlockStartHandler() { // clear raf if trying again window.cancelAnimationFrame(rafID); // set to desired value currValue = +this.value; } function unlockEndHandler() { // store current value currValue = +this.value; // determine if we have reached success or not if(currValue >= maxValue) { successHandler(); } else { rafID = window.requestAnimationFrame(animateHandler); } } // handle range animation function animateHandler() { // calculate gradient transition var transX = currValue - maxValue; // update input range inputRange.value = currValue; //Change slide thumb color on mouse up if (currValue < 20) { inputRange.classList.remove('ltpurple'); } if (currValue < 40) { inputRange.classList.remove('purple'); } if (currValue < 60) { inputRange.classList.remove('pink'); } // determine if we need to continue if(currValue > -1) { window.requestAnimationFrame(animateHandler); } // decrement value currValue = currValue - speed; } // handle successful unlock function successHandler() { alert('Unlocked'); }; // bind events inputRange.addEventListener('mousedown', unlockStartHandler, false); inputRange.addEventListener('mousestart', unlockStartHandler, false); inputRange.addEventListener('mouseup', unlockEndHandler, false); inputRange.addEventListener('touchend', unlockEndHandler, false); // move gradient inputRange.addEventListener('input', function() { //Change slide thumb color on way up if (this.value > 20) { inputRange.classList.add('ltpurple'); } if (this.value > 40) { inputRange.classList.add('purple'); } if (this.value > 60) { inputRange.classList.add('pink'); } //Change slide thumb color on way down if (this.value < 20) { inputRange.classList.remove('ltpurple'); } if (this.value < 40) { inputRange.classList.remove('purple'); } if (this.value < 60) { inputRange.classList.remove('pink'); } });
粒子
时间
文字
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号