效果预览
全部代码
<!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>
<style>
* {
margin: 0;
padding: 0;
}
.box {
width: 1000px;
height: 500px;
margin: auto;
position: relative;
}
.box .img {
height: 500px;
overflow: hidden;
}
.box img {
width: 1000px;
height: 0;
float: left;
display: block;
opacity: 0;
transition: opacity 1s;
}
.box .img .current {
opacity: 1;
height: 500px;
}
.left,
.right {
position: absolute;
width: 50px;
height: 100px;
background-color: #ccc;
top: 50%;
margin-top: -50px;
line-height: 100px;
font-size: 50px