1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> *{ margin: 0; padding: 0; } ul{ list-style: none; width: 500px; height: 40px; margin: 30px auto; display: flex; justify-content: space-around; cursor: pointer; } .active{ background-color: salmon; color: gold; font-size: 20px; border-bottom: aqua 5px solid; } li{ transition: all .3s linear; border-radius: 20%; } .shadow{ box-shadow: 0 0 10px 10px skyblue; } </style> </head> <body> <ul> <li class="active shadow">新闻</li> <li class="shadow">娱乐</li> <li class="shadow">国际</li> <li class="shadow">军事</li> <li class="shadow">汽车</li> <li class="shadow">生活</li> </ul> </body> </html> <script type="text/javascript"> var liArray=document.getElementsByTagName("li"); for (var i=0;i<liArray.length;i++) { liArray[i].onclick=function(){ this.className="active shadow"; for (var j=0;j<liArray.length;j++){ if(this!=liArray[j]){ liArray[j].className="shadow"; } } } } </script>
|