星空网 > 软件开发 > 网页设计

滑动条效果

准备将自己做的滑动条效果都放在这篇博文下。

自己的第一个成果

滑动条效果

css

body{    background: black;  }  #slider_1{    width: 400px;    height: 2px;    border-radius: 1px;    display: -webkit-flex;    position: relative;    margin: 30px auto;  }    #oSlider{    width: 15px;    height: 15px;    position: absolute;    border: 1px solid rgb(249,247,107);    border-radius: 10px;    background: rgb(249,247,107);    top: -7px;  }  #slider_11{    -webkit-flex:1;    background: rgb(249,247,107);    border-radius: 1px 0 0 1px;  }  #slider_12{    -webkit-flex:1;    background: rgba(255,255,255,0.3);    border-radius: 0 1px 1px 0px;  }

html

<div id="slider_1">    <div id="slider_11"></div>    <span id="oSlider"></span>    <div id="slider_12"></div>  </div>  

js

var slider_1=document.getElementById("slider_1");  var oSlider=document.getElementById("oSlider");  var width=400;  var min=-7;  var max=393;  var drag=false;  var slider_11=document.getElementById("slider_11");  var slider_12=document.getElementById("slider_12");  slider_1.onclick=function(){    var ewidth=event.clientX-slider_1.offsetLeft;    console.log(ewidth);    slider_11.style["-webkit-flex"]=ewidth/width;    slider_12.style["-webkit-flex"]=(width-ewidth)/width;    oSlider.style.left=ewidth+"px";        }  oSlider.onmousedown=function(){    drag=true;  }  document.onmousemove=function(){    if(drag){    var ewidth=event.clientX-slider_1.offsetLeft;    if(ewidth<=min||ewidth>=max) return false;    console.log(ewidth);    slider_11.style["-webkit-flex"]=ewidth/width;    slider_12.style["-webkit-flex"]=(width-ewidth)/width;    oSlider.style.left=ewidth+"px";    }  }  document.onmouseup=function(){    drag=false;  }

 




原标题:滑动条效果

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

亚马逊印度站又搞事情,已有数名卖家无辜中招!:https://www.ikjzd.com/articles/648
如何购买通用产品代码(UPC):https://www.ikjzd.com/articles/6480
7大技巧带你走出亚马逊CPC广告误区!:https://www.ikjzd.com/articles/6482
亚马逊SEO -如何优化A9算法的listing(上篇):https://www.ikjzd.com/articles/6485
如何解决亚马逊卖家FBA库存积压问题?:https://www.ikjzd.com/articles/6486
亚马逊SEO -如何优化A9算法的listing(下篇):https://www.ikjzd.com/articles/6488
对话上海文化广场|音乐剧的剧场怎么做?:https://www.xlkjsw.com/news/90169.html
链接评论中图片排序规则:https://www.kjdsnews.com/a/1841014.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流