Slider effect_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:46:24
Original
1150 people have browsed it

Prepare to put all the slider effects you made under this blog post.

My first result

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;    }  
Copy after login

 #num{
  font-size: 24px;
color: white;
display: block;
text-align: center;
>

js
 
Copy after login

var slider_1=document.getElementById("slider_1");

var oSlider=document.getElementById("oSlider");

var num=document.getElementById ("num");

<div id="slider_1">        <div id="slider_11"></div>        <span id="oSlider"></span>        <div id="slider_12"></div>    </div>    
Copy after login
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;
change(ewidth );

}
oSlider.onmousedown=function(){
drag=true;
}
document.onmousemove=function(){
if(drag){
var ewidth=event.clientX-slider_1.offsetLeft;
if(ewidth<=min||ewidth>=max) return ;
change(ewidth);
}
}
document.onmouseup=function(){
drag=false;
}
function change(ewidth){
num.innerText=Math.round((ewidth 6)/width*100);
slider_11.style["-webkit-flex"]=ewidth/width;
slider_12.style["-webkit-flex"]=(width-ewidth)/width;
oSlider.style.left =ewidth "px";
}




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template