位置固定且宽度 100% 的元素覆盖 IE 中的垂直滚动条

发布于 2024-09-12 08:47:38 字数 199 浏览 6 评论 0原文

我有一个宽度为 100% 且位置固定在页面顶部的 div。当 html 需要垂直滚动时,它会覆盖 IE 中的垂直滚动条。

我该怎么做才能避免这种情况(我无法更改位置固定位)?

我可以检测页面是否需要垂直滚动 onload/resize 并使用 jQuery 更改静态 div 的宽度吗?

或者

完全通过 CSS 解决它?

I have a div with WIDTH 100% and position fixed on the top of the page. It covers the vertical scrollbar in IE when vertical scrolling is needed on the html.

What can I do to avoid this (I can't change the position fixed bit)?

Can I detect whether page need vertical scrolling onload/resize and change that static div's width using jQuery?

or

Solve it through CSS altogether?

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

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

发布评论

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

评论(2

一场春暖 2024-09-19 08:47:38

发现问题:我不小心将 overflow:auto 附加到 body 标记上,而它仅适用于 html 标记。

Found the problem: I accidentally attached overflow:auto on the body tag when it was only meant for the html tag.

很酷又爱笑 2024-09-19 08:47:38

如果没有看到页面,很难说清楚,但是你可以添加一个条件样式表并在 ie 中将 div 移动超过 5px 左右,这样就不会发生这种情况吗?
right:5px

jquery 代码如下所示:

if ($(window).height() < $(document).height()) {
   $('#myDiv').css('left', '5px');
}

It is kinda hard to tell without seeing the page, but could you add a conditional stylesheet and move the div over 5px or so in ie so that doesn't happen?
right:5px

The jquery code for this would be something like:

if ($(window).height() < $(document).height()) {
   $('#myDiv').css('left', '5px');
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文