Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优先使用overflow:clip #111

Open
xinglie opened this issue Oct 27, 2023 · 0 comments
Open

优先使用overflow:clip #111

xinglie opened this issue Oct 27, 2023 · 0 comments

Comments

@xinglie
Copy link
Owner

xinglie commented Oct 27, 2023

很多时候我们使用overflow:hidden是为了隐藏溢出的内容

hidden在于内容可以以编程的方式滚动(例如,通过设置 scrollLeft 等属性的值或 scrollTo() 方法), 因此该元素仍然是一个滚动的容器。

除此之外,还有一个比较隐蔽的问题:overflow:hidden容器内在隐藏区域有可聚焦的元素或隐藏区域有一个元素被调用了scrollIntoView方法,那么浏览器依然会对这个overflow:hidden的容器进行滚动,尝试把聚焦或要展示的元素显示出来

如果确实要隐藏,不希望通过任意一种方式进行滚动,请使用overflow:clip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant