用于向页面滚动100%的jQuery向下滚动按钮

我正在制作一个网站,但是使用jQuery将页面向下滚动100%的按钮有问题.我遇到了麻烦,因为它在浏览器和窗口大小之间滚动不同的空格.我问题的任何解决方案?顺便说一句,这是我的代码……

jQuery的

var screenheight100 = css('height','100%');
$('#gdb1').click(function(){
    $("html,body").animate({ scrollTop: (screenheight100)},600);
    return false;
 });

HTML

<div class="gdBox"><div id="gdb1" class="gdbutton fontwhitenshadow">Q</div></div>

CSS

.gdBox{width: 100%;
       height: 35px;
       position: absolute;
       bottom: 30px; 
       text-align: center;
       overflow: visible;
}
.gdbutton{margin: 0 auto;
          height: 20px;
          padding-bottom: 20px;
          text-align: center;
          width: 40px;
          font-family: iconFont;
          font-size: 45px;
          cursor: pointer;
}

解决方法

我假设您要实现的是将窗口滚动为窗口高度.

但是css()不是一个全局函数,它是一个jQuery对象方法.

你可以通过.height()方法得到窗口的高度:

$('#gdb1').click(function(){
    $("html,body").animate({ scrollTop: $(window).height()},600);
    return false;
});

Working Fiddle

但是如果你想在元素顶部滚动窗口,你可以通过$(selector).offset().top获得所需的空间.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...