轮播代码
写法非常简单,下面是html部分:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>轮播</title> <link rel="stylesheet" href="lunbo.css" type="text/css"/> <script src="lunbo.js"></script> </head> <body> <div class="container"> <div id="pic" style="left:-1366px;"> <img src="5.jpg" alt="" num="5"> <img src="1.jpg" alt="" num="1"> <img src="2.jpg" alt="" num="2"> <img src="3.jpg" alt="" num="3"> <img src="4.jpg" alt="" num="4"> <img src="5.jpg" alt="" num="5"> <img src="1.jpg" alt="" num="1"> </div> <a href="javascript:;" id="prev" class="button"><</a> <a href="javascript:;" id="next" class="button">></a> <div id="start" class="button1">O</div> <div id="stop1" class="button1">X</div> </div> </body> </html>
css代码:
*{ margin: 0; padding: 0; text-decoration: none;} body{background: black;} .container{ height: 768px; width: 1366px; line-height: 768px; border: 3px black solid; margin: 0 auto; overflow: hidden; position: relative; top: 20px; } .container:hover .button{display: block;} .container:hover .button1{display: block;} #pic{ height: 1366px; width: 9562px; position: absolute; z-index: -1; } #pic img{float: left;} .button{ position: absolute; display: none; font-size: 60px; font-weight: bold; text-align: center; width: 70px; height: 70px; line-height: 70px; top: 359px; background: RGBA(0,0,0,.1); color: white; } .button:hover{background: RGBA(0,0,0,.3);} #prev{left: 30px;} #next{right: 30px;} .button1{ position: absolute; display: none; float: left; font-size: 40px; font-weight: bold; text-decoration: center; height: 40px; width: 40px; line-height: 40px; bottom: 10px; font-family: "微软雅黑"; color:RGBA(255,255,255,.7); cursor: pointer; } #start{left: 630px;} #stop1{left: 730px;}
js代码:
*{ margin: 0; padding: 0; text-decoration: none;}
body{background: black;}
.container{
height: 768px;
width: 1366px;
line-height: 768px;
border: 3px black solid;
margin: 0 auto;
overflow: hidden;
position: relative;
top: 20px;
}
.container:hover .button{display: block;}
.container:hover .button1{display: block;}
#pic{
height: 1366px;
width: 9562px;
position: absolute;
z-index: -1;
}
#pic img{float: left;}
.button{
position: absolute;
display: none;
font-size: 60px;
font-weight: bold;
text-align: center;
width: 70px;
height: 70px;
line-height: 70px;
top: 359px;
background: RGBA(0,0,0,.1);
color: white;
}
.button:hover{background: RGBA(0,0,0,.3);}
#prev{left: 30px;}
#next{right: 30px;}
.button1{
position: absolute;
display: none;
float: left;
font-size: 40px;
font-weight: bold;
text-decoration: center;
height: 40px;
width: 40px;
line-height: 40px;
bottom: 10px;
font-family: "微软雅黑";
color:RGBA(255,255,255,.7);
cursor: pointer;
}
#start{left: 630px;}
#stop1{left: 730px;}
实际效果图:

浙公网安备 33010602011771号