单击边距或填充滚动到特定div

时间:2017-10-24 17:08:36

标签: jquery html

我有这个Jquery代码滚动



      $(".index-down-scroll").click(function() {
          $('html,body').animate({
              scrollTop: $(".home-page-catalog").offset().top},
              'slow');
      });

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div style="position: fixed; left: 0px; top: 0px; right: 0px; z-index: 999; width: 100%; height: 96px; background-color: red;"></div>
<div style="background-color: green; height: 800px;">
<div class="index-down-scroll" style="text-align: center; margin-top: 120px; font-size: 40px;">Down</div>
    <div style="margin-top: 300px;" class="w-clearfix home-page-catalog">
        Some text
    </div></div>
&#13;
&#13;
&#13;

我发现了一个问题。我有固定的菜单高度:96px; 如果我使用Jquery代码,他会将我滚动到Div而不考虑固定菜单的事实。因此,Div正在关闭我的菜单。 这可以以某种方式纠正吗?例如,添加函数margin或padding?

0 个答案:

没有答案
相关问题