Files
ClassContent/历届学生/front-end-team-10/项目练习/学生项目/薛涛/2.28/轮播图v2.html
2024-09-27 02:06:13 +08:00

134 lines
3.4 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;
margin: 100px auto;
overflow: hidden;
position: relative;
}
.swiper .swiper_wrap {
display: flex;
position: relative;
transition: all 1s;
}
.swiper .swiper_wrap li {}
.swiper .swiper_wrap 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 div {
color: #fff;
font-size: 20px;
background: #000;
display: flex;
align-items: center;
justify-content: center;
width: 50px;
height: 50px;
cursor: pointer;
}
.swiper .button .left {}
.swiper .button .right {}
.swiper .dot {
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 20px;
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 banner">
<ul class="swiper_wrap" 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">
<div class="left">&#8249;</div>
<div class="right">&#8250;</div>
</div>
<ul class="dot"></ul>
</div>
</body>
<script src="./swiperV2.js"></script>
<script> var a = new Swiper(".banner", {
autoPlay: false,
time: 2000,
initialSlide: 0,
// on: {
// slideChange: function (index) {
// console.log("当前轮播图切换到:",index);
// },
// slideChange3: function (index) {
// console.log("当前轮播图切换到:",index);
// }
// },
})
document.querySelector("button").onclick = () => {
a.slideTo(2)
}
</script>
</html>