jquery - 无法在 $(windows).load() 上的 chrome 中设置 margin-top

标签 jquery css google-chrome safari

我尝试在页面加载时在 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/

相关文章:

javascript - 维护 https 和 http 之间的私钥

javascript - 使用 JavaScript 验证联系表单

jQuery - 将包装器的宽度除以内部 div 的数量

html - 如何将我的滚动条设置为只在一个 div 中显示

python - Django 模板扩展不调用 CSS

google-chrome - JsPDF - 不允许将顶部框架导航到数据 URL

javascript - 每 1 分钟在 chrome 中运行一个脚本

jquery - 如何仅通过在 jQuery 中按下键盘来搜索无序列表?

javascript - D3 从最右边的字符对齐轴左侧的文本

java - org.openqa.selenium.WebDriverException : disconnected: received Inspector. 使用 Selenium 和 Chromedriver 执行测试期间发生分离事件错误