console
$('.menu-w').on('click', function() {
$(this).toggleClass('on');
});
<div style="max-width:750px;margin:0 auto;">
<header class="header">
<a class="back-btn" href="javascript:history.back()"><i class="iconfont icon-back"></i></a>
<h1 class="h1vt">标题</h1>
<div class="menu-w">
<div class="top-icon-w">
<i class="icon-menu"></i>
</div>
</div>
<div class="sub-nav-w">
<ul class="sub-nav">
<li><a href="javascript:;"><i class="iconfont icon-home"></i>首页</a></li>
<li>
<a href="javascript:;"><i class="iconfont icon-ju"></i>开业聚惠</a>
</li>
<li>
<a href="javascript:;"><i class="iconfont icon-gou"></i>全球购</a>
</li>
<li>
<a href="javascript:;"><i class="iconfont icon-wuyi"></i>五一放价</a>
</li>
</ul>
</div>
</header>
</div>
body {
font: 16px Microsoft YaHei, sans-serif;
color: #2a2b2c;
background: #fff;
}
a {
text-decoration: none;
display: block;
color: #2a2b2c;
}
.header {
height: 50px;
position: relative;
background: #0cd;
}
.iconfont {
color: #555;
font-size: 24px;
vertical-align: -3px;
margin-right: 10px;
}
.back-btn {
width: 50px;
height: 50px;
position: absolute;
top: 0;
left: 0;
text-align: center;
}
.back-btn .iconfont {
color: #fff;
font: 30px/50px arial;
}
.h1vt {
font-size: 24px;
font-weight: normal;
line-height: 52px;
text-align: center;
padding: 0 60px 0 50px;
color: #fff;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.menu-w {
width: 60px;
height: 50px;
position: absolute;
top: 0;
right: 0;
z-index: 5;
}
.top-icon-w {
width: 26px;
height: 19px;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
}
.top-icon-w .icon-menu {
display: block;
font-style: normal;
width: 100%;
height: 2px;
border-radius: 0px;
background: #fff;
position: absolute;
top: 0;
bottom: 0;
margin: auto;
transition: opacity .15s;
}
.top-icon-w::before,
.top-icon-w::after {
content: '';
display: block;
width: 100%;
height: 2px;
border-radius: 0px;
background: #fff;
position: absolute;
left: 0;
-webkit-transition: transform .2s;
transition: transform .2s;
}
.top-icon-w::before {
top: 0;
-webkit-transform-origin: 0px 5px;
transform-origin: 0px 5px;
}
.top-icon-w::after {
bottom: 0;
-webkit-transform-origin: 5px 0px;
transform-origin: 5px 0px;
}
.menu-w.on .top-icon-w .icon-menu {
opacity: 0;
}
.menu-w.on .top-icon-w::before {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.menu-w.on .top-icon-w::after {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.menu-w.on + .sub-nav-w {
display: block;
}
.sub-nav-w {
display: none;
background: #fff;
border-radius: 5px;
box-shadow: 0 2px 10px #ddd;
position: absolute;
top: 55px;
right: 10px;
z-index: 2;
}
.sub-nav-w::before {
content: '';
width: 14px;
height: 14px;
background: #fff;
border-radius: 2px;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
position: absolute;
top: -6px;
right: 14px;
z-index: 3;
}
.sub-nav {
width: 170px;
}
.sub-nav li {
position: relative;
}
.sub-nav li::after {
content: '';
display: block;
width: 100%;
height: 1px;
background: #a5a5a5;
-webkit-transform: scaleY(.3);
transform: scaleY(.3);
position: absolute;
bottom: 0;
left: 0;
}
.sub-nav li:last-child::after {
display: none;
}
.sub-nav li a {
height: 50px;
line-height: 52px;
font-size: 18px;
padding: 0 14px;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sub-nav li a img {
display: inline-block;
vertical-align: -2px;
width: 20px;
height: 20px;
margin-right: 10px;
}
@media (max-width: 375px) {
.sub-nav {
width: 140px;
}
.iconfont {
font-size: 20px;
vertical-align: -1px;
margin-right: 7px;
}
.sub-nav li a {
font-size: 16px;
height: 45px;
line-height: 47px;
}
}