<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>javascript scroll production</title>
</head>
<body>
<style>
/*conment*/
*{
margin: 0;
padding: 0;
}
img{max-width: 100%;}
.container{
max-width: 620px;
margin: 0 auto;
padding-top: 50px;
}
.text-center{text-align: center;}
.list-inline li{
display: inline-block;
}
.hide{display: none;}
hr{
margin:20px 0;
}
.tag{
background-color: #ccc;
padding: 5px 0;
}
.tag li{
padding: 0 10px;
border-left: 1px solid #fff;
cursor:pointer;
}
.tag li:first-child{
border-left: transparent;
}
.tag {
background-color: #ddd;
}
.scroll{
position: relative;
padding: 10px;
margin-bottom: 20px;
background-color: #ddd;
}
.wrap{
overflow: hidden;
}
.content{
min-width: 3000px;
height: 200px;
}
.content ul{
float: left;
}
.content ul li{
display: inline-block;
max-width: 200px;
}
#prev,#next{
width: 50px;
height: 50px;
margin-top: -25px;
background-color: #ccc;
line-height: 50px;
text-align: center;
cursor: pointer;
}
#prev{
position: absolute;
left: 0;
top:50%;
border-radius: 0 25px 25px 0;
}
#next{
position: absolute;
right: 0;
top:50%;
border-radius: 25px 0 0 25px;
}
</style>
<div class="container">
<h1 class="text-center">Picture scrolling production</h1>
<hr>
<div class="scroll">
<div class="wrap" >
<div class="content" >
<ul >
<li> <img src="" alt=""> </li>
<li> <img src="" alt=""></li>
<li> <img src="" alt=""></li>
<li> <img src="" alt=""></li>
</ul>
<ul >
</ul>
</div>
</div>
<div >
prev
</div>
<div >
next
</div>
</div>
</div>
<script>
var wrap=('wrap');
var list1=('list1');
var list2=('list2');
var prev=('prev');
var next=('next');
//Create a copy of the content list
=;
//Change to the left
function scroll(){
if(>=){
=0;
}
else{
++;
}
}
timer = setInterval(scroll,1);
// Use clearInterval() for mouse stay
=function(){
clearInterval(timer);
}
=function(){
timer = setInterval(scroll,1);
}
//Accelerate left
function scroll_l(){
if(>=){
=0;
}
else{
++;
}
}
//Scroll to the right
function scroll_r(){
if(<=0){
+=;
}
else{
--;
}
}
=function(){
clearInterval(timer);
change(0)
}
=function(){
clearInterval(timer);
change(1)
}
function change(r){
if(r==0){
timer = setInterval(scroll_l,60);
= function(){
timer = setInterval(scroll_l,60);
}
}
if(r==1){
timer = setInterval(scroll_r,60);
= function(){
timer = setInterval(scroll_r,60);
}
}
}
</script>
</body>