Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我写了一个公式来使我制作的导航栏的位置居中,并且它正在加载。是否有一个函数我必须重写它以使其在每次更改窗口大小时再次运行?
$(document).ready(function () { $('#left').css({ 'margin-left': (($(window).width())/2)-190 }); )};
});您在关闭时有错字doc ready,请尝试将其包含在.resize()函数中:
});
doc ready
.resize()
$(document).ready(function () { $(window).resize(function(){ $('#left').css({ 'margin-left': ($(window).width()/2)-190 }); }).resize(); });