为什么固定元素会减慢 Firefox 中的滚动速度?

发布于 2024-07-05 19:02:55 字数 167 浏览 6 评论 0原文

为什么应用了 CSS position:fixed 的元素会导致 Firefox 在滚动其所在页面时占用 100% CPU? 有什么解决方法吗?

我在一些网站上注意到了这种行为,例如 StackOverflow 页面顶部的通知栏。 我正在使用 Linux,以防万一。

Why do elements with the CSS position: fixed applied to them cause Firefox to eat 100% CPU when scrolling the page they are in? And are there any workarounds?

I've noticed this behavior on a few sites, for example the notification bar at the top of the page on StackOverflow. I'm using Linux in case that matters.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

鯉魚旗 2024-07-12 19:02:55

该网站有一个固定元素“第一次使用 Stack Overflow?查看常见问题解答!”,并且在 Firefox 中速度非常慢。 但与 Opera 和 Chrome 配合使用效果更好。
FF3、Windows XP、ATI。

This website has a fixed element "First time at Stack Overflow? Check out the FAQ!", and it's slow as hell in firefox. Works better with Opera and Chrome though.
FF3, Windows XP, ATI.

听,心雨的声音 2024-07-12 19:02:55

如前所述,这是错误 #201307。 解决方法是禁用平滑滚动:

编辑 -> 首选项 -> 高级-> 常规选项卡 -> 取消选中“使用平滑​​滚动”

As already stated, this is bug #201307. The workaround is to disable smooth scrolling:

Edit -> Prefrences -> Advanced -> General tab -> uncheck "Use smooth scrolling"

电影里的梦 2024-07-12 19:02:55

这是 bugzilla 中报告的错误,

显然是一种解决方法(成功的报告不一) ..) 是禁用平滑滚动

只需在“编辑”> 中禁用平滑滚动即可 首选项> 高级。

It's a bug reported in bugzilla

Apparently a work-around (with mixed reports of success..) is to disable smooth-scrolling

Just disable smooth scrolling in Edit > Preferences > Advanced.

拍不死你 2024-07-12 19:02:55

您确定这里有直接链接吗? 您是否创建了一个包含固定元素的静态 HTML 页面来验证您的理论? 考虑到这些 CSS 属性的使用范围有多广泛,我认为无论您运行什么浏览器/操作系统,其他人现在都会注意到它。

Are you sure that there's a direct link here? Have you created a static HTML page with fixed elements to verify your theory? Given how widely these CSS properties are used, I'd think someone else would have noticed it by now, whatever browser/OS you're running.

随风而去 2024-07-12 19:02:55

它会消耗 CPU,因为浏览器必须在每次滚动更改时重新绘制整个视口,而不仅仅是新的可见区域

it eats CPU because the browser has to repaint the entire viewport every scroll change rather than just the newly visible area

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文