【发布时间】:2017-05-30 02:22:26
【问题描述】:
我正在使用 jQuery 开发移动导航栏。我有一个小问题,jQuery 与移动导航栏完美配合,但是当我将屏幕大小调整为桌面时,桌面导航消失了。
jQuery(document).ready(function() {
jQuery(".navtoggle").click(function() {
jQuery(".nav-menu").slideToggle();
});
});
移动断点 SASS
@include breakpoint(xxxs) {
header {
nav {
ul {
background: #6c49b8;
li {
display: block;
border-bottom: 1px solid rgba(0,0,0,.1);
border-left: none;
border-right: none;
padding: 15px;
&:last-child {
border-left: none;
border-right: none;
}
}
}
.sub-menu {
position: relative;
top: 0;
padding: 0px;
background-color: #563a92;
z-index: 1;
}
}
}
.second-navbar {
#open {
margin: 20px 0px;
display: block;
}
}
}
@include breakpoint(xxs) {
header {
nav {
ul {
background: #6c49b8;
li {
display: block;
border-bottom: 1px solid rgba(0,0,0,.1);
border-left: none;
border-right: none;
padding: 15px;
&:last-child {
border-left: none;
border-right: none;
}
}
}
.sub-menu {
position: relative;
top: 0;
padding: 0px;
background-color: #563a92;
z-index: 1;
}
}
}
.second-navbar {
#open {
height: auto;
margin: 20px 0px;
display: block;
}
}
}
@include breakpoint(xs) {
header {
nav {
ul {
background: #6c49b8;
li {
display: block;
border-bottom: 1px solid rgba(0,0,0,.1);
border-left: none;
border-right: none;
padding: 15px;
&:last-child {
border-left: none;
border-right: none;
}
}
}
.sub-menu {
position: relative;
top: 0;
padding: 0px;
background-color: #563a92;
z-index: 1;
}
}
}
.second-navbar {
#open {
height: auto;
margin: 20px 0px;
display: block;
}
}
}
@include breakpoint(sm) {
header {
nav {
ul {
background: #6c49b8;
li {
display: block;
border-bottom: 1px solid rgba(0,0,0,.1);
border-left: none;
border-right: none;
padding: 15px;
&:last-child {
border-left: none;
border-right: none;
}
}
}
.sub-menu {
position: relative;
top: 0;
padding: 0px;
background-color: #563a92;
z-index: 1;
}
}
}
.second-navbar {
#open {
height: auto;
margin: 20px 0px;
display: block;
}
}
}
@include breakpoint(table) {
header {
nav {
ul {
background: #6c49b8;
li {
display: block;
border-bottom: 1px solid rgba(0,0,0,.1);
border-left: none;
border-right: none;
padding: 15px;
&:last-child {
border-left: none;
border-right: none;
}
}
}
.sub-menu {
position: relative;
top: 0;
padding: 0px;
background-color: #563a92;
z-index: 1;
}
}
}
.second-navbar {
#open {
height: auto;
margin: 20px 0px;
display: block;
}
}
}
@include breakpoint(md) {
header {
nav {
ul {
background: #6c49b8;
li {
display: block;
border-bottom: 1px solid rgba(0,0,0,.1);
border-left: none;
border-right: none;
padding: 15px;
&:last-child {
border-left: none;
border-right: none;
}
}
}
.sub-menu {
position: relative;
top: 0;
padding: 0px;
background-color: #563a92;
z-index: 1;
}
}
}
.second-navbar {
#open {
height: auto;
margin: 20px 0px;
display: block;
}
}
}
【问题讨论】: