生产一个五页轮播图完整代码html
时间: 2023-12-07 12:04:26 浏览: 28
以下是一个简单的五页轮播图的完整HTML代码,包括HTML、CSS和JavaScript部分:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>五页轮播图</title>
<style>
/* 轮播图容器样式 */
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
/* 图片样式 */
.mySlides {
display: none;
}
img {
vertical-align: middle;
max-width: 100%;
}
/* 左右箭头样式 */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}
/* 图片底部圆点样式 */
.dot-container {
text-align: center;
padding: 20px;
background: #ddd;
}
.dot {
cursor: pointer;
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active, .dot:hover {
background-color: #717171;
}
</style>
</head>
<body>
<div class="slideshow-container">
<!-- 图片 -->
<div class="mySlides">
<img src="img1.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="img2.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="img3.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="img4.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="img5.jpg" style="width:100%">
</div>
<!-- 左右箭头 -->
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
<!-- 图片底部圆点 -->
<div class="dot-container">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
<span class="dot" onclick="currentSlide(4)"></span>
<span class="dot" onclick="currentSlide(5)"></span>
</div>
</div>
<script>
var slideIndex = 1;
showSlides(slideIndex);
// 下一张/上一张
function plusSlides(n) {
showSlides(slideIndex += n);
}
// 当前图片
function currentSlide(n) {
showSlides(slideIndex = n);
}
// 显示图片
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}
</script>
</body>
</html>
```