|
@@ -0,0 +1,145 @@
|
|
|
+<!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>
|
|
|
+ <link rel="stylesheet" href="font/iconfont.css">
|
|
|
+ <style>
|
|
|
+ * {
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ ul {
|
|
|
+ list-style: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ #container {
|
|
|
+ width: 590px;
|
|
|
+ height: 470px;
|
|
|
+ margin: 100px auto;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ #img-box {
|
|
|
+ width: 2950px;
|
|
|
+ left: 0;
|
|
|
+ position: absolute;
|
|
|
+ transition: left 1s linear;
|
|
|
+ }
|
|
|
+
|
|
|
+ #img-box img {
|
|
|
+ float: left;
|
|
|
+ }
|
|
|
+
|
|
|
+ #btns {
|
|
|
+ position: absolute;
|
|
|
+ right: 20px;
|
|
|
+ bottom: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #btns li {
|
|
|
+ width: 20px;
|
|
|
+ height: 20px;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 20px;
|
|
|
+ background: cyan;
|
|
|
+ border-radius: 10px;
|
|
|
+ color: white;
|
|
|
+ float: left;
|
|
|
+ margin-right: 7px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #btns .select {
|
|
|
+ background: red;
|
|
|
+ }
|
|
|
+
|
|
|
+ #prev,
|
|
|
+ #next {
|
|
|
+ width: 40px;
|
|
|
+ height: 40px;
|
|
|
+ position: absolute;
|
|
|
+ top: 215px;
|
|
|
+ opacity: 0.4;
|
|
|
+ /* display: none; */
|
|
|
+ }
|
|
|
+
|
|
|
+ #next {
|
|
|
+ right: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ #prev span {
|
|
|
+ font-size: 40px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #next span {
|
|
|
+ font-size: 40px;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+ <div id="container">
|
|
|
+ <div id="img-box">
|
|
|
+ <img class="actived" src="image/1.jpg" alt="">
|
|
|
+ <img class="actived" src="image/2.jpg" alt="">
|
|
|
+ <img class="actived" src="image/3.jpg" alt="">
|
|
|
+ <img class="actived" src="image/4.jpg" alt="">
|
|
|
+ <img class="actived" src="image/5.jpg" alt="">
|
|
|
+ </div>
|
|
|
+ <ul id="btns">
|
|
|
+ <li class="select">1</li>
|
|
|
+ <li>2</li>
|
|
|
+ <li>3</li>
|
|
|
+ <li>4</li>
|
|
|
+ <li>5</li>
|
|
|
+ </ul>
|
|
|
+ <div id="prev">
|
|
|
+ <span class="iconfont icon-shangyige"></span>
|
|
|
+ </div>
|
|
|
+ <div id="next">
|
|
|
+ <span class="iconfont icon-xiayige"></span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <script>
|
|
|
+ //transtion: 延迟方向 延迟时间 Linear匀速
|
|
|
+ var btns = document.getElementById('btns')
|
|
|
+ var uli = btns.getElementsByTagName('li')
|
|
|
+ var imgs = document.getElementsByClassName('actived')
|
|
|
+ var imgBox = document.getElementById('img-box')
|
|
|
+ var next = document.getElementById('next')
|
|
|
+ var prev = document.getElementById('prev')
|
|
|
+
|
|
|
+ var iNow = 0
|
|
|
+ //点击按钮事件
|
|
|
+ for (var i = 0; i < uli.length; i++) {
|
|
|
+ uli[i].index = i
|
|
|
+ uli[i].onclick = function () {
|
|
|
+ for (var j = 0; j < uli.length; j++) {
|
|
|
+ uli[j].className = ''
|
|
|
+ }
|
|
|
+ iNow = this.index
|
|
|
+ this.className = 'select'
|
|
|
+ imgBox.style.left = -590 * iNow + 'px'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //点击下一个
|
|
|
+ next.onclick = function () {
|
|
|
+ iNow++;
|
|
|
+ if(iNow > 4){
|
|
|
+ iNow = 0
|
|
|
+ }
|
|
|
+ for (var j = 0; j < uli.length; j++) {
|
|
|
+ uli[j].className = ''
|
|
|
+ }
|
|
|
+ uli[iNow].className = 'select'
|
|
|
+ imgBox.style.left = -590 * iNow + 'px'
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+
|
|
|
+</html>
|