180 lines
4.1 KiB
HTML
180 lines
4.1 KiB
HTML
<!DOCTYPE html>
|
|
<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>
|
|
<link rel="stylesheet" href="http://at.alicdn.com/t/c/font_3888527_7tklo9l16jl.css">
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
list-style: none;
|
|
}
|
|
|
|
.swiper {
|
|
width: 630px;
|
|
height: 315px;
|
|
overflow: hidden;
|
|
position: relative;
|
|
margin: 100px auto;
|
|
}
|
|
|
|
.swiper .photo {
|
|
display: flex;
|
|
position: absolute;
|
|
transition: all 1s;
|
|
}
|
|
|
|
.swiper .photo li {}
|
|
|
|
.swiper .photo li img {
|
|
width: 630px;
|
|
height: 315px;
|
|
}
|
|
|
|
.swiper .button {
|
|
width: 100%;
|
|
position: absolute;
|
|
top: 50%;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
transform: translateY(-50%);
|
|
}
|
|
|
|
|
|
.swiper .button i {
|
|
font-size: 30px;
|
|
color: black;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 50px;
|
|
height: 50px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.swiper .dot {
|
|
position: absolute;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
bottom: -100px;
|
|
display: flex;
|
|
}
|
|
|
|
.swiper .dot li {
|
|
width: 13px;
|
|
height: 13px;
|
|
background: #fff;
|
|
border-radius: 100%;
|
|
margin-right: 10px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.swiper .dot li:last-child {
|
|
margin-right: 0px;
|
|
}
|
|
|
|
.swiper .dot .active {
|
|
background: red;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="swiper">
|
|
<ul class="photo" style=" left: 0px;">
|
|
<li>
|
|
<img src="https://img.alicdn.com/imgextra/i4/6000000003174/O1CN01cpv0cZ1ZJjvVWrUuo_!!6000000003174-2-octopus.png"
|
|
alt="">
|
|
</li>
|
|
<li>
|
|
<img src="https://img.alicdn.com/imgextra/i2/6000000003386/O1CN01ySmLuo1asptKSfbHC_!!6000000003386-0-octopus.jpg"
|
|
alt="">
|
|
</li>
|
|
<li>
|
|
<img src="https://img.alicdn.com/imgextra/i3/6000000000084/O1CN012wKWpe1CUW5EEs61K_!!6000000000084-0-octopus.jpg"
|
|
alt="">
|
|
</li>
|
|
</ul>
|
|
<div class="button">
|
|
<i class="iconfont icon-zuojiantou1"></i>
|
|
<i class="iconfont icon-zuojiantou1-copy"></i>
|
|
|
|
<ul class="dot">
|
|
<li class="active"></li>
|
|
<li></li>
|
|
<li></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
|
|
var timeId = null, index = 0
|
|
|
|
$(".icon-zuojiantou1").onclick = () => {
|
|
sport(1)
|
|
}
|
|
$(".icon-zuojiantou1-copy").onclick = () => {
|
|
sport(-1)
|
|
}
|
|
|
|
_(".dot li").forEach((v, i) => {
|
|
v.onclick = () => {
|
|
changeDotActive(i)
|
|
}
|
|
})
|
|
|
|
$(".swiper").onmouseover = () => {
|
|
clearInterval(timeId)
|
|
}
|
|
|
|
$(".swiper").onmouseout = () => {
|
|
auto()
|
|
}
|
|
|
|
function sport(offset) {
|
|
index += offset
|
|
if (index < 0) {
|
|
index = 0
|
|
}
|
|
if (index > 2 ) {
|
|
index = 2
|
|
}
|
|
if (index >= 0 && index <= 2) {
|
|
|
|
changeDotActive(index)
|
|
}
|
|
|
|
}
|
|
function changeDotActive(i) {
|
|
_(".dot li").forEach(val => {
|
|
val.classList.remove("active")
|
|
})
|
|
_(".dot li")[i].classList.add("active")
|
|
$(".photo").style.left = `${i * -630}px`
|
|
}
|
|
|
|
function auto() {
|
|
timeId = setInterval(() => {
|
|
$(".icon-zuojiantou1-copy").onclick()
|
|
}, 2000)
|
|
}
|
|
|
|
auto()
|
|
|
|
|
|
|
|
function $(className) {
|
|
return document.querySelector(className)
|
|
}
|
|
|
|
function _(className) {
|
|
return document.querySelectorAll(className)
|
|
}
|
|
</script>
|
|
|
|
</html> |