因此,我创建了可切换的叠加菜单,在所有主流浏览器(甚至在Internet Explorer中)中进行了测试,除了在 Firefox (在第46版中测试)之外,它的工作正常无处不在!
问题是,按" MENU "切换叠加层时按钮," 关闭"叠加中的按钮没有出现,用户卡在打开的菜单中 这应该是什么样的: 这看起来像 所以我要求你的帮助,因为我已经没有想法了。
https://jsfiddle.net/fpgkzd2x/5/ - 摆弄工作代码。
<header class="main-nav flex-vhcenter-parent">
<div class="button ">
<p>MENU</p>
</div>
</header>
<nav class="overlay">
<header class="main-nav flex-vhcenter-parent">
<div class="button ">
<p>CLOSE</p>
</div>
</header>
</nav>
$menu-color: #3c948b;
.flex-vhcenter-parent{
display: -ms-flexbox;
display: flex;
justify-content: center;
align-items: center;
}
/* Main Nav menu styles */
.button{
transform: scale(1.3);
transition: all 500ms;
}
.main-nav{
display: flex;
width: 100%;
transition: all 500ms;
z-index: 20;
background-color: $menu-color;
position: fixed;
&.fixed{
.button{
transition: all 500ms;
transform: scale(1);
}
}
}
header > div{
width: 20%;
display: flex;
align-items: center;
justify-content: center;
}
.main-nav p{
margin: 0;
font-size: 1.5em;
}
/* Toggleable Overlay */
.overlay{
z-index: 30;
position: fixed;
width: 100%;
height: 100%;
background-color: #000;
opacity: 0.90;
top: -100%;
transition: top 100ms ease-out;
.button{
margin: 0;
color: #fff;
}
}
.opened{
top: 0%;
transition: top 100ms ease-out;
}
overlay = $(".overlay");
$(".button").click(function(event){
overlay.toggleClass("opened");
});
答案 0 :(得分:2)
Firefox不完全支持Display flex 它看起来像你期望的吗?
$menu-color: #3c948b;
.flex-vhcenter-parent{
display: block;
justify-content: center;
align-items: center;
}
/* Main Nav menu styles */
.button{
transform: scale(1.3);
transition: all 500ms;
margin: 0 auto;
}
.main-nav{
display: inline-block;
width: 100%;
transition: all 500ms;
z-index: 20;
background-color: $menu-color;
position: absolute;
text-align: center;
&.fixed{
.button{
margin: 0 auto;
transition: all 500ms;
transform: scale(1);
}
}
}
header > div{
width: 20%;
display: block;
align-items: center;
justify-content: center;
}
.main-nav p{
margin: 0 auto;
font-size: 1.5em;
}
/* Toggleable Overlay */
.overlay{
z-index: 30;
position: fixed;
width: 100%;
height: 100%;
background-color: #000;
opacity: 0.90;
top: -100%;
transition: top 100ms ease-out;
.button{
margin: 0 auto;
color: #fff;
}
}
.opened{
top: 0%;
transition: top 100ms ease-out;
}