Code writing: (The format of writing is a bit poor, make a good look, but the function is implemented)
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled </title>
<script type= "Text/javascript" src= "./jquery-1.8.0.min.js" ></script>
<style type= "Text/css" >
. silder{
width:80%;
height:20px;
margin:0 Auto;
margin-top:100px;
Background-color:green;
position:relative;
}
. silderimg{
margin-top:-2px;
margin-left:0px;
}
. silderline{
height:200px;
margin-left:12px;
background-color:red;
width:1px;
}
#content {
Position:absolute;
left:0px;
top:0px;
}
</style>
<body id= "Body" >
<div class= "Silder" >
<div id= "Content" >
<IMG id= "img" class= "silderimg" src= "./silder.png" >
<div class= "Silderline" ></div>
</div>
</div>
<script type= "Text/javascript" >
var oevent=new Function (' e ', ' if (!e.clientx) e = E.changedtouches[0];return e ')
function TouchMove (e) {
E.preventdefault ();
var parent=$ (this). Parent () [0];
var temp=$ (parent). Parent () [0].offsetleft;
var x = oevent (e). ClientX;
var OldLeft = ($ (parent). CSS ("left"). Replace ("px", "")/1);
var changex = x-temp;
if (Changex <=-12) {
Changex =-12;
}else if (Changex >= $ (parent). Parent (). Width ()-12) {
Changex = $ (parent). Parent (). Width ()-12;
}
Console.log (Changex);
$ (parent). CSS ("left", Changex);
}
document.getElementById (' img '). AddEventListener ("Touchmove", Touchmove, false);
</script>
</body>
Mobile-side JS implementation slider push