下滑线跟随导航

Original 2019-05-16 11:38:43 171
abstract:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>下滑线跟随导航</title> <script type="text/javascript" src=".
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>下滑线跟随导航</title>
	<script type="text/javascript" src="../jQuery/jquery-3.3.1.min.js"></script>
	<style type="text/css">
		*{margin: 0;padding: 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>
	<script type="text/javascript">
		$(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>
</head>
<body>
	<div class="menu">
		<ul>
			<li name="0">首页</li>
			<li name="1">国际新闻</li>
			<li name="2">娱乐天地</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>
</body>
</html>


Correcting teacher:查无此人Correction time:2019-05-17 09:29:56
Teacher's summary:完成的不错。每行js语句结束增加;号。继续加油

Release Notes

Popular Entries