最垃圾的轮播图
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
position: relative;
margin: 0 auto;
}
body{
z-index: 10000;
}
ul{
list-style: none;
display: flex;
position: relative;
}
.one>li{
width: 500px;
height: 300px;
position: absolute;
left: 50%;
margin-left:-250px;
}
.one>:nth-last-child(4){
background-color: blanchedalmond;
}
.one>:nth-last-child(3){
background-color: rgb(73, 3, 186);
}
.one>:nth-last-child(2){
background-color: rgb(102, 4, 70);
}
.one>:nth-last-child(1){
background-color: rgb(3, 88, 0);
}
.one>:nth-last-child(5){
background-color: rgb(211, 203, 203);
}
.one>:nth-last-child(6){
background-color: rgb(147, 0, 0);
}
.qq{
z-index: 1;
}
#long{
width: 25px;
height: 80px;
position: absolute;
left: 50%;
margin-left:225px;
margin-top: 110px;
z-index: 1000000000;
opacity: 0.5;
}
#mong{
width: 25px;
height: 80px;
position: absolute;
left: 50%;
margin-left:-250px;
margin-top: 110px;
z-index: 1000000000;
opacity: 0.5;
}
.two{
z-index: 544455448848;
width: 250px;
height: 120px;
margin: 0 50%;
margin-top: 250px;
}
.two>li{
width: 20px;
height: 20px;
border: 1px solid violet;
border-radius: 50%;
margin-left: 12px;
background-color: black;
}
</style>
</head>
<body>
<div class="">
<ul class="one">
<li class="oo qq">0</li>
<li class="oo">1</li>
<li class="oo">2</li>
<li class="oo">3</li>
<li class="oo">4</li>
<li class="oo">5</li>
</ul>
<button id="long" οnclick="one()">></button>
<button id="mong" οnclick="two()"><</button>
</div>
<ul class="two">
<li class="jong"></li>
<li class="jong"></li>
<li class="jong"></li>
<li class="jong"></li>
<li class="jong"></li>
<li class="jong"></li>
</ul>
</body>
<script>
var ul= document.getElementsByClassName('oo')
var long = document.getElementById('long')
var mong = document.getElementById('mong')
var jongs = document.getElementsByClassName('jong')
var bodys = document.getElementsByTagName("div")
var i =0;
var p= 2
//左切换
function one(){
if(i<ul.length-1){
i++
ul[i].style.zIndex=p
console.log('i'+i);
console.log(p)
p++
}else if(i=ul.length-1){
i=0
ul[i].style.zIndex=p
console.log(i);
console.log(p)
p++
}
}
//右切换
function two(){
if(i!=0){
i--
ul[i].style.zIndex=p
p++
}else{
i=ul.length-1
ul[i].style.zIndex=p
p++
}
}
//自动轮播
var aaa=setInterval('one()',1500)
// console.log(jongs);
for (var u = 0, len = jongs.length; u < len; u++) {
(function (j) {
//点圆点切换对应的图
jongs[j].onclick = function () {
p++
ul[j].style.zIndex=p
console.log(p);
}
var ppo=2
//点击停止自动轮播
if(ppo%2==0){
ppo++
ul[j].onclick = function(){
clearInterval(aaa)
// console.log(ppo);
} }
})(u)
}
</script>
</html>