|
@@ -0,0 +1,83 @@
|
|
|
+<!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;
|
|
|
+ }
|
|
|
+ ul{
|
|
|
+ list-style: none;
|
|
|
+ }
|
|
|
+ #container{
|
|
|
+ width: 590px;
|
|
|
+ height: 470px;
|
|
|
+ margin: 100px auto;
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
+ .selected{
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ .choice{
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+ #btns{
|
|
|
+ position: absolute;
|
|
|
+ right: 10px;
|
|
|
+ bottom: 10px;
|
|
|
+ }
|
|
|
+ #btns li{
|
|
|
+ width: 20px;
|
|
|
+ height: 20px;
|
|
|
+ background: aqua;
|
|
|
+ float: left;
|
|
|
+ color: white;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 20px;
|
|
|
+ border-radius: 10px;
|
|
|
+ margin-right: 5px;
|
|
|
+ }
|
|
|
+ #btns .select{
|
|
|
+ background: red;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <div id="container">
|
|
|
+ <div id="img-box">
|
|
|
+ <img class="selected choice" src="image/1.jpg" alt="">
|
|
|
+ <img class="selected" src="image/2.jpg" alt="">
|
|
|
+ <img class="selected" src="image/3.jpg" alt="">
|
|
|
+ <img class="selected" src="image/4.jpg" alt="">
|
|
|
+ <img class="selected" 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>
|
|
|
+ <script>
|
|
|
+ var btn = document.getElementsByTagName('li')
|
|
|
+ var imgs = document.getElementsByClassName('selected')
|
|
|
+
|
|
|
+ for(var i=0;i<btn.length;i++){
|
|
|
+ btn[i].index = i
|
|
|
+ btn[i].onclick = function(){
|
|
|
+ for(var j=0;j<btn.length;j++){
|
|
|
+ btn[j].className = ''
|
|
|
+ imgs[j].className = 'selected'
|
|
|
+ }
|
|
|
+ this.className = 'select'
|
|
|
+ imgs[this.index].className = 'selected choice'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|