奇怪的行为 IE8 选择框向上显示并超出浏览器限制

发布于 2024-12-02 19:01:06 字数 2420 浏览 0 评论 0原文

在 IE8 中,仅包含大约 50 个选项的简单选择就会溢出到浏览器窗口之外

是否有已知的解决方法?

如果是这样,有人有例子吗?

谢谢, Ernie

在 IE8 中尝试此代码

<select name="test" size=1>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
</select>
  1. 调整浏览器大小,使其小于列表。
  2. 单击选择控件,然后看到它从浏览器窗口中弹出。

Just a simple select with about 50 options will overflow outside the browser window in IE8

Is there a known workaround for this?

If so, does anyone have an example?

Thanks,
Ernie

Try this code in IE8

<select name="test" size=1>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
  <option value="x">X</option>
</select>
  1. Resize your browser to make it smaller than the list.
  2. Click the select control and see it pop off your browser window.

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

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

发布评论

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

评论(1

忆沫 2024-12-09 19:01:06

我已经复制了您报告的问题。我在打开兼容模式的 IE7、IE8 和 IE8 中运行它,所有三个浏览器实例都显示了相同的问题。

然而,这可能是按照设计的。如果溢出包含在浏览器内,则用户将不得不滚动浏览选项以进行选择,并且如果他们想要的选项超出了浏览器窗口的高度,则他们将不得不使用浏览器上的水平滚动条进行滚动向下完成查看

你提到它在 IE7 中不会发生,但在我的测试中却发生了。我还没有在 FF、Chrome、Safari 或 Opera 中尝试过这个,但我假设如果所有现代浏览器都共享这个“故障”,那么这不是一个设计缺陷,而是故意的,让搜索变得很大 <在尚未最大化以适合整个屏幕宽度的浏览器窗口中查看网页时,“选择>”框更容易。

当用户可以只使用一个滚动条时,为什么要让他们使用两个滚动条呢?我同意这看起来有点傻,但我相信它背后有一些逻辑。

选择框 ie8 故障的屏幕截图

希望这会有所帮助。

编辑:

只是添加。这可能是有意为之的另一个原因是溢出是否隐藏在整个页面上。请参阅第二个屏幕截图:

selectbox with Overflow hide

如您所见,我添加了以下 css:

 <style type="text/css">
 /* <![CDATA[ */
 html {
 overflow: hidden;
 }
 /* ]]> */
 </style>

它消除了浏览器的本机水平滚动条。如果

简而言之,我认为没有解决方法。这不是 CSS 问题,而是浏览器中对本机功能的控制限制。就像您无法强制用户是否在新选项卡或新窗口中打开链接一样,您也无法强制选择框保留在浏览器的框架内。有些事情是我们无法控制的。

问候,

I've replicated the issue you reported. I ran it in IE7, IE8, and IE8 with compatibility mode turned on, and all three browser instances revealed the same issue. The <select> overflow goes beyond the frame of the browser.

This could be, however, as designed. If the overflow was contained within the browser, the user would have to scroll through the options to choose from, and if the option they desired is beyond the height of the browser window, they would have to use the horizontal scrollbar on the browser to scroll down to finish viewing the rest of the options in the <select> box.

You had mentioned it does not happen in IE7, but in my test it did. I have not tried this in FF, Chrome, Safari or Opera yet, but I would assume that if all modern browsers share this "glitch", then it is not a design flaw but rather intentional, to make searching a large <select> box easier when viewing a web page in a browser window that has not been maximized to fit the width of the entire screen.

Why make the user use two scrollbars when they can simply use one? I agree it looks a little silly, but I believe there's some logic behind it.

screenshot of selectbox ie8 glitch

Hope this helps.

EDIT:

Just to add. Another reason this maybe intentional, is if overflow is hidden on the overall page. See second screenshot:

selectbox with overflow hidden

as you can see I added the following css:

 <style type="text/css">
 /* <![CDATA[ */
 html {
 overflow: hidden;
 }
 /* ]]> */
 </style>

which eliminated the browser's native horizontal scrollbar. If the <select> box did not overflow beyond the frame of the browser window, the user may not be able to view all the options.

In short I don't think there is a workaround for this. This is not a CSS issue, but rather a limitation of control over native functions in the browser. The same way you can't force whether a user opens a link in a new tab or a new window, you can't force the select box to stay within the browser's frame. Some things are out of our control.

Regards,

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