gpt4 book ai didi

javascript - 在 Firefox 中失败

转载 作者:太空宇宙 更新时间:2023-11-04 08:57:08 25 4
gpt4 key购买 nike

您好,我想将此代码放入我的网站,但是当我尝试单击 Firefox 中的菜单按钮时,它会弹出,然后背景从正常颜色变为白色(或消失)。

http://jsfiddle.net/Xroad/3pn2pkt6/19/

$('.toggle-menu').click(function (e) {
e.preventDefault();
$('h4.toggle-menu').text($(this).text() == 'Menu' ? 'Close' : 'Menu');

$('.circle').toggleClass('Opacity');
$('#overlay-menu').delay(5000).toggleClass('Opacity');
$('.circle').toggleClass('open');

});
html, body {
height: 100%;
}

body {
background: #fffdee;
}

.circle {
position: fixed;
top: -50%;
left: -50%;
height: 50%;
width: 50%;
border-radius: 50%;
background: #98694d;
opacity: 0;
-webkit-transition-duration: 0.5s;
-webkit-transition-property: all;
-webkit-transition-timing-function: ease-in-out;
transition: all 0.5s ease-in-out;
z-index: 1;
}

.open {
top: -50%;
left: -50%;
width: 200%;
height: 200%;
}

#overlay-menu {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
text-align: center;
color: black;
opacity: 0;
z-index: 4;
}

h4.toggle-menu {
position: fixed;
top: 20px;
right: 70px;
color: black;
cursor: pointer;
z-index: 5;
}

.Opacity {
opacity: 1 !important;
visibility: visible;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="circle"></div>

<nav id="home-menu" class="menu">
<h4 class="toggle-menu">Menu</h4>
</nav>

<div id="overlay-menu"><p>MY CONTENT</p></div>

最佳答案

这有效:(.open 类中的小改动(向其添加了不透明度)),并删除了 JS 中的一行。在 Firefox 和 Chrome 中测试

$('.toggle-menu').click(function (e) {
e.preventDefault();
$('h4.toggle-menu').text($(this).text() == 'Menu' ? 'Close' : 'Menu');

//$('.circle').toggleClass('Opacity');
$('#overlay-menu').delay(5000).toggleClass('Opacity');
$('.circle').toggleClass('open');

});
html, body {
height: 100%;
}

body {
background: #fffdee;
}

.circle {
position: fixed;
top: -50%;
left: -50%;
height: 50%;
width: 50%;
border-radius: 50%;
background: #98694d;
opacity: 0;
-webkit-transition-duration: 0.5s;
-webkit-transition-property: all;
-webkit-transition-timing-function: ease-in-out;
transition: all 0.5s ease-in-out;
z-index: 1;
}

.open {
top: -50%;
left: -50%;
width: 200%;
height: 200%;
opacity: 1;
}

#overlay-menu {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
text-align: center;
color: black;
opacity: 0;
z-index: 4;
}

h4.toggle-menu {
position: fixed;
top: 20px;
right: 70px;
color: black;
cursor: pointer;
z-index: 5;
}

.Opacity {
opacity: 1 !important;
visibility: visible;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="circle"></div>

<nav id="home-menu" class="menu">
<h4 class="toggle-menu">Menu</h4>
</nav>

<div id="overlay-menu"><p>MY CONTENT</p></div>

关于javascript - 在 Firefox 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43036157/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com