返回导航下划线跟随...登陆

导航下划线跟随

ifhover2019-05-06 13:32:31251
<!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>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送