Javascript 如何向下滚动到文档或身体高度的90%?
我想向下滚动到文档或正文高度的90%,而不是设备屏幕高度的90%。我知道下面的示例将向下滚动到我的页面或文档的某个元素Javascript 如何向下滚动到文档或身体高度的90%?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我想向下滚动到文档或正文高度的90%,而不是设备屏幕高度的90%。我知道下面的示例将向下滚动到我的页面或文档的某个元素 $("html, body").animate({ scrollTop: $("#emptydisplay").offset().top }, 500); 但这不是我需要的。我需要自动向下滚动到HTML文档高度的90%。我试过这样的东西 $('html,body').animate({ scrollTop: $(document).height() * 0.90 });
$("html, body").animate({ scrollTop: $("#emptydisplay").offset().top }, 500);
但这不是我需要的。我需要自动向下滚动到HTML文档高度的90%。我试过这样的东西
$('html,body').animate({ scrollTop: $(document).height() * 0.90 });
但它一直向下滚动到底部
在jquery中如何实现这一点?谢谢…你应该减去窗户的高度
$('html,body').animate({ scrollTop: $(document).height() * 0.90 - $(window).height() });
你应该减去窗户的高度
$('html,body').animate({ scrollTop: $(document).height() * 0.90 - $(window).height() });
scrollTop表示窗口的顶部。scrollTop:100%表示页面的全高-窗口的高度。如果您想要90%,您需要:
$('html,body').animate({ scrollTop: $(document).height() * 0.9 - $(window).height() }, 500);
scrollTop表示窗口的顶部。scrollTop:100%表示页面的全高-窗口的高度。如果您想要90%,您需要:
$('html,body').animate({ scrollTop: $(document).height() * 0.9 - $(window).height() }, 500);
您应该从文档高度中删除窗口高度
$('html,body').animate({ scrollTop: ($(document).height() * 0.90)-$(window).height() });
您应该从文档高度中删除窗口高度
$('html,body').animate({ scrollTop: ($(document).height() * 0.90)-$(window).height() });
使用BodyHight窗口高度的90%您可以设置小提琴/jsbin吗?我看到它在工作fine@mohamedrias我不知道为什么它会在你的小提琴上起作用,但在我的页面上,它不会像我预期的那样起作用。但现在已经解决了。感谢所有的帮助…干杯使用90%的Bodyhight窗口高度您能设置小提琴/jsbin吗?我看到它在工作fine@mohamedrias我不知道为什么它会在你的小提琴上起作用,但在我的页面上,它不会像我预期的那样起作用。但现在已经解决了。感谢所有提供帮助的人…仅在本页中打开控制台并进行测试仅在本页中打开控制台并进行测试