<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.box {
position: relative;
border-radius: 10px;
height: 100px;
width: 270px;
}
.img {
position: absolute;
z-index: -1;
}
img {
position: absolute;
border-radius: 10px;
z-index: -1;
}
img:nth-of-type(2) {
left: 270px;
}
img:nth-of-type(3) {
left: 540px;
}
img:nth-of-type(4) {
left: 810px;
}
ul {
color: white;
overflow: hidden;
margin: 0 auto;
margin-top: 30px;
}
li {
position: absolute;
list-style: none;
height: 20px;
width: 20px;
background: ghostwhite;
border-radius: 50%;
line-height: 20px;
text-align: center;
color: black;
}
li:nth-of-type(1) {
top:70px;
left: 160px;
}
li:nth-of-type(2) {
top:70px;
left: 190px;
}
li:nth-of-type(3) {
top:70px;
left: 220px;
}
li:nth-of-type(4) {
top:70px;
left: 250px;
}
li:hover{
color: red;
cursor:pointer;
}
li:nth-of-type(1):hover~.img {
left:0px;
}
li:nth-of-type(2):hover~.img {
left:-270px;
}
li:nth-of-type(3):hover~.img {
left:-540px;
}
li:nth-of-type(4):hover~.img {
left:-810px;
}
</style>
</head>
<body>
<ul class="box">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<div class="img">
<img src="../img/img1.png" />
<img src="../img/img2.png" />
<img src="../img/img3.png" />
<img src="../img/img4.png" />
</div>
</ul>
</body>
CSS样式实现轮播图效果
最新推荐文章于 2024-04-15 10:28:24 发布