<!DOCTYPE html>
<html>
<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>
*{
padding: 0;
margin: 0;
}
.container{
position: relative;
}
.container>img{
width: 100%;
height: 500px;
position: absolute;
display: none;
}
ul{
margin-left: 10px;
list-style: none;
background-color: greenyellow;
position: absolute;
border-radius: 20px;
left: 40%;
bottom: 20px;
}
ul > li{
width: 15px;
height: 15px;
border-radius: 50%;
background-color: rgba(0, 0, 0,0.5);
float: left;
}
.li_selected{
background-color: white;
}
</style>
<script>
window.onload() =>{
let img_arr =document.querySelectorAll(".container>img")
let index = 0
let timer =setInterval(change,3000)
function change(){
img_arr[index].style.display = "none";
index = ++ index % img_arr.length
img_arr[index].style.display = "block"
}
let li_arr = document.querySelectorAll ("ul>li")
}
</script>
</head>
<body>
<div class = "container">
<img style="display: block;" src="材料/4667a3b13e85c8ac.jpg" alt="">
<img src="./材料/O1CN01VdLw1q1aV1ElCJIZl_!!1726463334.jpg" alt="">
<img src="./材料/ef94adf005547d89-46fa40787a4c2886-87bcd674eb065fe7941e302a5a522de5.jpg" alt="">
</div>
<ul>
<li class="li_selected"></li>
<li></li>
<li></li>
</ul>
</body>
</html>
前端banner试验练习(部分)
于 2023-03-31 23:36:37 首次发布