滑动条

<!DOCTYPE html >
< html lang= "en" >
< head >
< meta charset= "UTF-8" >
< meta name= "viewport" content= "width=device-width, initial-scale=1.0" >
< meta http-equiv= "X-UA-Compatible" content= "ie=edge" >
< title >滑动条 </ title >
< style type= "text/css" >
*{ margin: 0; padding: 0}
body{ padding-top: 30px; text-align: center}
/*谷歌浏览器样式开始 */
input[ type= range ] {
/* 轨道的样式 */
-webkit-appearance: none;
outline: none;
width: 600px;
height: 20px;
border-radius: 10px;
box-shadow: 0 1px 1px 0 #ddd inset;
background: -webkit-linear-gradient( #f80f80, #f80f80) no-repeat, #eee;
background-size: 1% 100%;
}
input[ type= range ]::-webkit-slider-thumb {
/* 滑块的样式 */
-webkit-appearance: none;
height: 34px;
width: 34px;
background: #FF5C5C;
border-radius: 50%; /*外观设置为圆形*/
border: solid 4px #fff; /*设置边框*/
box-shadow: 0 0 0 #3b4547; /*添加底部阴影*/
}
/*谷歌浏览器样式结束 */
/* 火狐浏览器样式开始 */
input[ type= range ]::-moz-range-progress {
background: -moz-linear-gradient( left, #f80f80, #f80f80);
height: 20px;
border-radius: 10px;
}
input[ type= range ]::-moz-range-track {
background: #eee;
height: 20px;
border-radius: 10px;
}
input[ type= range ]::-moz-range-thumb {
/* 滑块的样式 */
-webkit-appearance: none;
height: 34px;
width: 34px;
background: #FF5C5C;
border-radius: 50%; /*外观设置为圆形*/
border: solid 4px #fff; /*设置边框*/
box-shadow: 0 0 0 #3b4547; /*添加底部阴影*/
}
/* 火狐浏览器样式结束 */
< / style >
</ head >
< body >
< input type= "range" value= "0" min= "0" max= "100" step= "5" id= "jsChange" >
<!-- min最小值,max最大值,step每次移动的步数 -->
</ body >
< script type= "text/javascript" >
jsChange. oninput = function(){
this. style. backgroundSize= this. value+ '% 100%';
}
< / script >
</ html >

非常简单的滑动条,兼容谷歌、火狐、IE9+;

效果如下


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值