完美轮播图源码如下:
<!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>
<style>
* {
margin: 0;
padding: 0;
}
body{
background-color: aqua;
}
ul {
list-style: none;
}
/* 外面的大盒子 */
#wrap {
overflow: hidden;
position: relative;
width: 585px;
height: 467px;
margin: 100px auto 0;
}
#wrap .img-list {
display: flex; /* 这样子图片就是水平排列 */
position: relative;
left: 0px;
width: 100%;
height: 100%;
transform: 0.5s ease;/* 添加过渡效果 */
}
#wrap .img-list img {
width: 100%;
height: 100%;
cursor: pointer;/* 鼠标小手 */
}
/* a里放 小箭头 */
#wrap a {
position: absolute;
top: 50%;
transform: translate(0, -50%);
display: block;
width: 40px;
height: 50px;
background-color: rgba(0, 0, 0, 0.5);