gpt4 book ai didi

javascript - 在 Javascript 中单击“确定”之前如何禁用 div 转换?

转载 作者:行者123 更新时间:2023-11-28 03:27:21 25 4
gpt4 key购买 nike

我正在使用 Noty 插件。

插件出现在 onPageLoad 时事件被触发,并告诉您悬停标题 <div> .

然而,Noty位于它的正下方。如果将标题悬停在 <div> ,它展开,留下 Noty在顶端。看起来一团糟。

z-index我可以让它保持下来,但这不是我想要的。我需要禁用 header:hover在您确认 Noty 之前被禁用.让它在 JSFiddle 上工作是不可能的,但这是靠近 main 的代码:

CSS:

.header {
overflow: hidden;
background:#FFF;
border-bottom:1px solid gray;
box-shadow:0 0 10px;
height:70px;
position:fixed;
top:0px;
width:100%;
z-index:2;
background: rgb(210,255,82); /* Old browsers */
background: -moz-linear-gradient(top, rgba(210,255,82,1) 0%, rgba(145,232,66,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(210,255,82,1)), color-stop(100%,rgba(145,232,66,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(210,255,82,1) 0%,rgba(145,232,66,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(210,255,82,1) 0%,rgba(145,232,66,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(210,255,82,1) 0%,rgba(145,232,66,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(210,255,82,1) 0%,rgba(145,232,66,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d2ff52', endColorstr='#91e842',GradientType=0 ); /* IE6-9 */
transition: height 0.8s ease;
transition-delay: 1s;
}

.header:hover {
height: 120px;
transition: height 0.8s ease;
}

.noty {
top: 70px;
position: relative;
}

HTML

<div class="header">
<img src="artotek_ico.gif" height="70px" style="padding-bottom: 10px;" />
<span class="kielet">
<nav>

<!--Englanti-->
<a href="en_index.html" title="Englanniksi">In English</a>

<!--Ruotsi-->
<a href="swe_index.html" title="Ruotsiksi">På Svenska</a>

<!--Venäjä-->
<a href="ru_index.html" title="Venäjäksi">По русски</a>
</span>
</div>

<div class="noty">
<!--jQuery Plugins Declarations-->

</div>

JavaScript

var n = noty()
};

function generate(layout) {
var n = noty({
text: layout,
type: 'information',
text: 'Change your language here! Dismiss this by clicking.',
dismissQueue: true,
layout: layout,
theme: 'defaultTheme'
});
console.log('html: '+n.options.id);
}

function generateAll() {
generate('top');
generate('topCenter');
}

$(document).ready(function() {

generateAll();

});

$.noty.top = {
layout: 'top',
theme: 'defaultTheme',
type: 'information',
text: '',
dismissQueue: true, // If you want to use queue feature set this true
template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
animation: {
open: {height: 'toggle'},
close: {height: 'toggle'},
easing: 'swing',
speed: 500 // opening & closing animation speed
},
timeout: 500, // delay for closing event. Set false for sticky notifications
force: false, // adds notification to the beginning of queue when set to true
modal: false,
maxVisible: 5, // you can set max visible notification for dismissQueue true option
closeWith: ['click'], // ['click', 'button', 'hover']
callback: {
onShow: function() {},
afterShow: function() {},
onClose: function() {},
afterClose: function() {}
},
buttons: false // an array of buttons
};

最佳答案

将页眉的悬停类更改为此:

.header.enabled:hover {
height: 120px;
transition: height 0.8s ease;
}

这会将 CSS :hover 样式限制为当 .header 也具有类 enabled 时。

然后在适当的 noty 回调中添加或删除 .header 上的 enabled 类,例如

onShow: function() { $(".header").removeClass("enabled"); },
onClose: function() { $(".header").addClass("enabled"); },

关于javascript - 在 Javascript 中单击“确定”之前如何禁用 div 转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20374476/

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