直接使用代码
<style>
/* 公共顶部样式 */
#nav{background: #12b7f5;border-bottom:1px solid #83c8ed;position:fixed;top:0; width:100%; z-index: 9999;}
.mask{width:100%; height:100%; position:fixed; top:80;min-height:2000px; z-index: 9988; display:none}
.mask2{width:100%; height:80px; position:absolute; top:0;min-height:80px; z-index: 9988; display:none }
#nav .nav-logo{width:20%;float:left;}
#nav .nav-logo img{margin-left:4px;width:40px;margin-top:10px;}
#nav .nav-title{font-size:16px; color:#fff;line-height:20px;padding-top:20px;text-align:center;float: left;width:60%; }
#nav .nav-bar{width:20%; position:relative;float:right;text-align: right}
#nav .nav-bar img.nav-line{float:right;margin:15px; margin-top:22px;}
#nav .nav-bar .nav-content{display:none; position:absolute; top:60px; right:0px;border-radius:3px; width:100px; z-index: 9999; background:#333; }
#nav .nav-bar .nav-content .arrow{display:block; float:right;margin-right:16px;margin-top:-10px;}
#nav .nav-bar .nav-content ul{margin-top:8px;text-align: left;}
#nav .nav-bar .nav-content li a{ color:#ffffff; display:inline-block; line-height:30px; padding-left:10px;}
</style>
<!-- 导航条 -->
<div id="nav" class="container">
<div class="mask2"></div><!-- 导航遮罩层 -->
<div class="nav-logo">
<a href="/m/index">
<img src="/Public/images/img11.jpg" class="logo" />
</a>
</div>
<div class="nav-title">
心理咨询-德道幸福
</div>
<div class="nav-bar">
<img src="/Public/images/code/200305/line.png" width="30" class="nav-line" />
<div class="nav-content">
<img src="/Public/images/code/200305/arrow.png" class="arrow" />
<ul>
<li><a href="">首页</a></li>
<li><a href="">关于我们 </a></li>
<li><a href="">德福简介</a></li>
<li><a href="">心理专家</a></li>
<li><a href="">心理故事</a></li>
<li><a href="">招商加盟</a></li>
<li><a href="">联系我们</a></li>
<li><a href="/m/login">登录</a><a href="/m/zhuce">注册</a></li>
</ul>
</div>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="mask"></div><!-- 导航遮罩层 -->
<script type="text/javascript">
$(function () {
//手机导航显示隐鲹操作
var a = true;
$('.nav-line').click(function () {
a = !a;
console.log(a)
if (a) {
$('.nav-content').hide();
} else {
$('.nav-content').show();
$('.mask').show();
$('.mask2').show();
}
})
//单击页面导航区域以外可关闭导航操作
$('.mask').click(function (e) {
$('.nav-content').hide();
$('.nav-content-blue').hide();
$('.mask').hide();
$('.mask2').hide();
b = true;
a = true;
console.log(b)
});
//单击页面导航区域以外可关闭导航操作
$('.mask2').click(function (e) {
$('.nav-content').hide();
$('.nav-content-blue').hide();
$('.mask').hide();
$('.mask2').hide();
b = true;
a = true;
console.log(b)
});
//页面滚动关闭导航
$(document).scroll(function (e) {
$('.nav-content').hide();
$('.nav-content-blue').hide();
$('.mask').hide();
$('.mask2').hide();
a = true;
b = true;
});
})
</script>