当我隐藏一个div时,它会将其下面的div向上推

时间:2018-07-10 11:19:09

标签: javascript jquery html css


我正在尝试制作一个向下滚动动画,其中用户单击一个按钮,向下滚动到一个div并删除其上方的两个div。但是,我的问题是该动画在chrome上运行良好,但是在Firefox和safari上,该按钮实际上使您滚动到了div的开头。

我想要的输出是https://wearebarbarian.com/

我的JS:

$(document).on('click', 'a[href^="#index"]', function (event) {
    event.preventDefault();

    $('html, body').animate({
        scrollTop: $($.attr(this, 'href')).offset().top - 100
    }, 1200);
    $('.introsection').delay(1300).hide(0);
    $('#swipe-down').delay(1300).hide(0);
    $('body').css('overflowY', 'scroll');
    $('#home-mobile-nav').css('position', 'fixed');
    $('#home').css('margin-top', '0');
});

我认为问题是:

$('.introsection').delay(1300).hide(0);
    $('#swipe-down').delay(1300).hide(0);

有没有更好的隐藏div的方法。

我的问题的密码笔是https://codepen.io/mrsalami/pen/GBRmgx

1 个答案:

答案 0 :(得分:0)

对CSS使用-webkit-, -moz-来制作特定于浏览器的CSS。 -webkit-适用于Chrome和Safari,-moz-适用于Firefox。 只有定义与边距和填充相关的特定CSS,内容的设计才能在整个浏览器中保持不变。