我尝试在页面加载时在 chrome 中使用 JQuery margin-top 进行设置。
$(window).load(function(){
var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
var isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
if (isChrome) {
//alert("You are using Chrome!");
$('.footer_links').css("margin-top","0px;");
}
if (isSafari) {
//alert("You are using Safari!");
$('.footer_links').css("margin-top","10px;");
}
在 Safari 上运行良好,但在 chrome 上运行失败。但是当我想改变背景颜色时:
$('.footer_links').css("background-color","red");
它适用于 Chrome 和 Safari。
预先感谢您的帮助!
最佳答案
使用
$('.footer_links').css("margin-top", "0");
代替
$('.footer_links').css("margin-top", "0px;");
关于jquery - 无法在 $(windows).load() 上的 chrome 中设置 margin-top,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27064487/