摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>下劃線跟隨導(dǎo)航</title> <style> * { padding: 0; margin: 0; } ul { list-style: none; z-index: 20; position: relative; font-size: 15px; } li { float: left; cursor: pointer; width: 100px; height: 30px; text-align: center; line-height: 30px; color: #fff; font-weight: bold; } .menu { width: 500px; position: relative; margin: 20px auto; height: 32px; box-shadow: 0 2px 20px #000; background: #AF3434; border-radius: 3px; } </style> </head> <body> <div class="menu"> <ul> <li name="0">首頁</li> <li name="1">php中文網(wǎng)</li> <li name="2">獨(dú)孤九劍</li> <li name="3">西門大官人</li> <li name="4">滅絕師太</li> </ul> <div class="block" style="z-index:10;width:100px;height:2px;background:#fff;position:absolute;top:30px;"></div> </div> <script src="lib/jquery-3.3.1.js"></script> <script> $(function () { $('li').hover( function () { $x = parseInt($(this).attr('name')) * 100; $('.block').stop().animate({ left: $x + 'px' }, 300) }, function () { $('.block').stop().animate({ left: '0px' }, 300) } ) }) </script> </body> </html>
批改老師:查無此人批改時(shí)間:2019-03-23 15:16:33
老師總結(jié):完成的不錯(cuò), 下次把代碼縮進(jìn),讓代碼看著整齊,繼續(xù)加油。