使用webkit-scrollbar-滚动到最下面的问题 [英] Using webkit-scrollbar - scroll to bottom issue

查看:243
本文介绍了使用webkit-scrollbar-滚动到最下面的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用::-webkit-scrollbar选择器,该选择器在body标签上需要以下CSS:

I am using the ::-webkit-scrollbar selector which requires the following css on the body tag:

body { position:absolute; top:0; left:10px; bottom:0; right:10px; overflow-y:scroll; overflow-x:hidden; }

我需要使用以下jQuery向下滚动页面以显示页面底部附近的元素:

I need to have the page scroll down to reveal an element, which is near the bottom of the page, using the following jQuery:

$('.tester').click(function() { $('html, body').animate({ scrollTop: $(document).height() }, 'slow'); return false; }); 

由于body标签上的 position:absolute 声明,此行为无效.如果删除此选项,则向下滚动行为将按预期工作,但会弄乱webkit-scrollbar样式.

This behaviour doesn't work due the position:absolute declaration on the body tag. If I remove this, the scrolling down behaviour works as expected, but it messes-up the webkit-scrollbar styling.

有人能想到解决方法吗?

Can anyone think of a workaround?

推荐答案

好吧,经过大量的搜索和研究,我得出的结论是这根本行不通.

Well, after much searching and playing around, I have concluded that this just isn't going to work.

这主要是因为上面的CSS首先是一种黑客,目的是使浏览器隐藏本机滚动条并在主体内显示Webkit样式的版本.

This is mainly as the CSS above is a hack in the first place, to get the browser to hide the native scrollbar and show the webkit styled version within the body.

希望这会在将来由Webkit团队考虑,提供实现该功能的方法,而不必求助于在body标签上使用绝对定位.

Hopefully this will be considered by the webkit team in the future, providing ways to implement this functionality without having to resort to using absolute positioning on the body tag.

不幸的是,至少在现在,我不得不放弃使用自定义滚动条,因为我必须对此项目具有scrollTop功能.

Unfortunately, for now at least, I have had to abandon using the custom scrollbars as I must have scrollTop functionality for this project.

这篇关于使用webkit-scrollbar-滚动到最下面的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆