导航下划线跟随

Original 2019-05-06 13:32:31 252
abstract:<!DOCTYPE html> <html> <head> <title>document</title> <meta charset="utf-8"/> <script type="text/javascript" src="jq
<!DOCTYPE html>
<html>
<head>
<title>document</title>
<meta charset="utf-8"/>
<script type="text/javascript" src="jquery.js"></script>
<style type="text/css">
*{padding:0;margin:0;}
ul {list-style: none;z-index:20;position:relative;font-size: 15px;}
li:last-child{border-width: 0}
li {border-right:1px solid #CCC;float:left;cursor:pointer;width:100px;height: 32px;text-align:center;line-height:32px;color: #fff;font-weight: bold;}
.menu{width:504px;position:relative;margin:20px auto;height:32px;;background: rgb(0, 111, 236);border-radius:3px;border:1px solid rgb(0, 111, 236); }
.block{z-index:10;width:100px;height:2px;background:#fff;position:absolute;top:0px;}
</style>
<script type="text/javascript">
$(function(){
$('li').hover(
function(){
$x=parseInt($(this).attr('name'))*101
$('.block').stop().animate({left:$x+'px'})
},
function(){
$('.block').stop().animate({left:'0px'})
}  
)
})
</script>
</head>
<body>
<div class="menu">
<ul>
<li name="0">首页</li>
<li name="1">菜单1</li>
<li name="2">菜单2</li>
<li name="3">菜单3</li>
<li name="4">菜单4</li>
</ul>
<div class="block"></div>

</div>
</body>
</html>


Correcting teacher:查无此人Correction time:2019-05-07 09:39:35
Teacher's summary:今天看到你做了不少作业。不错,继续加油。 每行js语句,最后增加;号。记住了。

Release Notes

Popular Entries