html彩色滑动条,html+css实现彩色渐变滑动条

效果:

c906f6ff1d97f281c4fa1e2ec34e8e9a.png

实现代码(需要引入jquery):

* {

padding: 0;

margin: 0;

}

.slider-panel {

background-color: #fcc688;

height: 450px;

width: 600px;

padding: 20px;

margin: auto;

}

.slider-panel .slider-box {

background-color: darkgray;

margin-top: 40px;

display: inline-block;

width: 305px;

height: 6px;

position: relative;

border-radius: 5px;

}

/* 滑条划过的宽度,默认值为0 */

.slider-panel .slider-box .slider-value {

background-image: linear-gradient(90deg, #82E0F7 0%, #009DDC 52%);

height: 6px;

width: 0;

border-radius: 5px;

}

/* 滑条的样式。默认透明 */

.slider-panel input {

position: absolute;

left: 0;

top: 0;

-webkit-appearance: none;

-ms-appearance: none;

background: transparent;

width: 305px;

height: 2px;

outline: none;

}

/* 圆形滑块的样式 */

.slider-panel input[type=range]::-webkit-slider-thumb {

-webkit-appearance: none;

height: 12px;

width: 12px;

background-color: #eaecee;

border-radius: 50%;

cursor: pointer;

box-shadow: 0 2px 4px 0 #212B35;

background: #4BBEEC;

border: 2px solid #FFFFFF;

}

$(function() {

//绑定鼠标滑动事件

$(' .slider-panel input').on('mousemove touchmove touchend click', moveSlider)

function moveSlider() {

// 获取当前滑条的动态值

let sliderValue = parseInt($(this).val());

// 将滑条的值赋值给滑条划过后p标签的宽度

$('.slider-value').css('width', sliderValue + '%');

// 显示当前滑条的动态值

$('.slider-percentage').text(sliderValue);

}

})

彩色渐变滑动条

0%

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值