Javascript 子菜单位置问题
我在我的网站上有一个滚动菜单,它工作得很好,但在子菜单(公司和服务)中有一个bug,当页面滚动时,子菜单看起来很奇怪。我想我需要固定的子菜单位置,但当我试图使它,我有可怕的结果 我的代码:(或者你可以查看我的网站) stickymenu.jsJavascript 子菜单位置问题,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我在我的网站上有一个滚动菜单,它工作得很好,但在子菜单(公司和服务)中有一个bug,当页面滚动时,子菜单看起来很奇怪。我想我需要固定的子菜单位置,但当我试图使它,我有可怕的结果 我的代码:(或者你可以查看我的网站) stickymenu.js $( document ).ready(function() { var left = document.getElementById("zt-mainmenu"); stop = (left.offsetTop - 60); window.ons
$( document ).ready(function() {
var left = document.getElementById("zt-mainmenu");
stop = (left.offsetTop - 60);
window.onscroll = function (e) {
var scrollTop = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
if (scrollTop >= stop) {
left.className = 'fixed_m';
} else {
left.className = '';
}
}
});
我尝试添加此css,但没有得到预期的结果:
div.submenu-wrap {
position:fixed !important;
top:0px !important;
left:0px !important;
}
我不能提供完整的css代码,因为样式文件很大,但若你们期待这个网站,我想你们可以找到正确的答案。
有人能帮我吗?谢谢。您有一个js插件正在插入的顶级属性。编辑插件以删除顶级内联属性,或在现有选择器上使用此CSS位:
div.menusys_mega .menusub_mega {
position: absolute;
opacity: 0;
top: inherit !important;
}
这是不理想的,因为它的!重要,但至少您会看到取消top属性时会发生什么。一些脚本正在设置子菜单的位置,它是?