IE8 和 IE9 选择框悬停时会自行关闭
我遇到了这个奇怪的问题,如主题所示:在 IE 中(我正在测试版本 8,无法测试较旧/较新的版本),并且仅在 IE 中,当我将鼠标悬停在我的网站上时,我网站上的所有选择框都开始自行关闭鼠标选择一个选项。 这不会发生在 Firefox 上,也不会发生在我的本地服务器上,仅发生在测试远程服务器上(是的,这两个站点是相同的)。 所以,回顾一下: 本地版本:一切都很好,即使在 IE 中也是如此。 远程版本:当我将鼠标悬停在 IE 的选择框上时,它们就会“崩溃”。 有什么想法吗?
I got this weird problem as in topic: in IE (i'm testing version 8, got no way to test older/newer versions) and only in IE all the select boxes on my website started to close themselves as soon as i hover my mouse to select an option.
This isn't happening on Firefox, and this isn't happening on my local server, only on the test remote server (yes, the two sites are identical).
So, to recap it:
Local version: all fine, even in IE.
Remote version: IE's select boxes "crash" as soon as i hover on them.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我仅在 IE8 中遇到此问题,解决方法如下:
在 CSS 中,我将字体系列应用于
SELECT
。相反,我将其应用于
SELECT OPTION
。因此,我没有这样做:
我这样做了:
菜单停止不规则地关闭。希望这对某人有帮助。
I had this problem in IE8 only and here's how I solved it:
In my CSS I was applying a font-family to the
SELECT
.Instead I applied it to the
SELECT OPTION
.So instead of this:
I did this:
And the menu stopped closing erratically. Hope this helps someone.
我发现问题在于在字体系列的名称中添加引号。
写,而是声明了
所以,我没有
I found that the problem was in adding quotes in the name of the font-family.
So, instead of writing
i've declared
我也有同样的问题。就我而言,它与 Javascript 完全无关,与您的链接所暗示的相反。原来是简单的CSS。
最终我发现,将
color
属性应用到我的select
输入的 CSS 中,使用黑色以外的任何内容都会导致它们无法使用。该值是十六进制还是 RGB 并不重要,只要它是黑色即可。我将条件注释添加到目标 IE 7 或 8(即使 7 很好,但我需要它用于兼容模式下的 IE 8),并设置此样式声明:
I was having the same issue. In my case it was totally unrelated to Javascript, contrary to what your link implies. Turned out to be simple CSS.
Eventually I discovered that applying a
color
attribute to myselect
inputs' CSS with anything other than black would render them unusable. It didn't matter if the value was in hex or rgb, as long as it was black.I put a conditional comment to target IE 7 or 8 (even though 7 was fine, I need it for IE 8 in compatibility mode), and set up this style declaration:
我遇到了同样的问题,解决方案如下:
select 的父级有必要的字体选项。
感谢您的回答这个问题
I've got the same problem and the solution is following:
and the parent of select has necessary font option.
Thank for this answer this question
看起来可能是一些不同的 CSS 声明导致了这种情况。
我遇到了同样的问题,但没有颜色声明。事实证明这是字体系列规则。我使用条件注释来定位 IE8 及更早版本,并将字体系列设置为“继承”。填充效果很好,字体大小也很好。
It looks like it might be a few different CSS declarations that can cause this.
I was having the same problem but no color declaration. It turns out that it was a font-family rule. I used a conditional comment to target IE8 and older and set the font-family to "inherit." Padding works fine, as does font-size.
我花了一整天的时间研究这个问题,但是是在 IE9 中。我正在分享我的解决方案,因为它不是由于
select
的color
或font-family
引起的。事实证明,当 IE 在
select
中发现一个option
具有指定的opacity
CSS 值时,它会崩溃。即使不透明度被另一个具有opacity: none
或opacity: 1
的 CSS 规则覆盖,该属性甚至不应该出现。这是一个令人毛骨悚然的浏览器错误。
I spent a whole day investigating this issue but in IE9. I'm sharing my solution since it wasn't because of the
color
orfont-family
of theselect
.It turns out that IE freaks out when it finds an
option
inside aselect
that has a specified CSS value foropacity
. The issue happens even if the opacity is overridden by another CSS rule withopacity: none
oropacity: 1
, the property shouldn't even appear.It's a creepy browser bug.
我在IE9下也遇到过这个问题。这是由于 @font-face 语句,其中 font-family 属性等于真实的 font-family 名称。在 IE11 中运行良好。
I've had this issue in IE9 also. It was due to @font-face statements where you have the font-family property equal to the real font-family name. In IE11 it works fine.
那救了我:
PS。即使背景颜色已经在 css 文件中设置,也需要重置背景颜色。
That saved me:
PS. Need to reset background color even if it's already set in css file.