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>轮播图</title>
<link rel="stylesheet" href="轮播图.css">
<link rel="stylesheet" href="reset.css">
</head>
<body>
<div class="container">
<input type="radio" id="radis1" name="choose" checked>
<input type="radio" id="radis2" name="choose">
<input type="radio" id="radis3" name="choose">
<div class="wrap">
<img src="../img/wallhaven-4262dg.jpg" alt="">
<img src="../img/wallhaven-d56v8m.png" alt="">
<img src="../img/wallhaven-w8r6wx.png" alt="">
</div>
<div class="tool">
<label for="radis1">
</label>
<label for="radis2">
</label>
<label for="radis3">
</label>
</div>
</div>
</body>
</html>
css
html,
body {
height: 100vh;
width: 100vw;
display: table-cell;
}
.container {
width: 600px;
height: 400px;
border: 1px solid rgba(0, 0, 0, .2);
border-radius: 6px;
position: relative;
margin: auto;
overflow: hidden;
}
.container .wrap {
position: absolute;
width: inherit;
height: inherit;
top: 0;
left: 0;
display: flex;
flex-wrap: nowrap;
transition: all .5s ease;
}
.container .wrap img {
width: inherit;
height: inherit;
}
.container input {
position: relative;
z-index: 2;
}
.tool {
position: absolute;
bottom: 0px;
left: 50%;
width: 100%;
transform: translate(-50%, 0);
text-align: center;
line-height: 35px;
background-color: rgba(0, 0, 0, .2);
}
.tool label {
display: inline-block;
width: 15px;
height: 15px;
border: 3px solid #fff;
border-radius: 50%;
background-color: #fff;
margin-right: 15px;
cursor: pointer;
}
input {
display: none;
}
input:nth-child(1):checked~.tool label:nth-child(1) {
background-color: pink;
}
input:nth-child(2):checked~.tool label:nth-child(2) {
background-color: pink;
}
input:nth-child(3):checked~.tool label:nth-child(3) {
background-color: pink;
}
input:nth-child(1):checked~.wrap {
transform: translateX(0%)
}
input:nth-child(2):checked~.wrap {
transform: translateX(-100%)
}
input:nth-child(3):checked~.wrap {
transform: translateX(-200%);
}