IE 不透明度:有时会悬停?

发布于 2024-09-16 06:51:11 字数 2244 浏览 6 评论 0原文

我在 IE 中遇到了一个非常奇怪的不透明度/悬停问题。 FF 和 Chrome 中一切正常。

考虑这一页:

<!DOCTYPE html>
<html>
    <head>
    <title></title>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#outer").css("opacity", .7);
        });
    </script>
    <style type="text/css">
        #outer
        {
            position: absolute;
            width:600px;
            background: #111;
            z-index:2;
            overflow: hidden;
        }
        #outer div
        {
            float: left;
        }
        ul
        {
            list-style: none;
            margin: 0;
            padding: 0;
        }
        ul li 
        {
            width: auto;
            margin: 2px 4px 2px 4px;
            padding: 2px 4px 2px 4px;
            font-size: 11px;
            color: White;
        }
        ul li:hover
        {
            background: red;
            font-weight: 600;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="outer">
        <div id="one">
            <ul>
                <li>111</li>
                <li>222</li>
            </ul>
        </div>
        <div id="two">
            <ul>
                <li>333</li>
                <li>444</li>
            </ul>
        </div>
        <div id="three">
            <ul>
                <li>555</li>
                <li>666</li>
            </ul>
        </div>
    </div>
</body>
</html>

这就是问题所在。鼠标悬停是间歇性的 - 您可能会或可能不会在 IE(7 或 8)中看到红色背景和字体变化。您将始终看到光标发生变化。如果我去掉背景和字体粗细,我仍然看到光标发生变化。但是,如果背景或字体粗细存在,光标仍然会改变,但背景或字体可能会也可能不会。

如果 #outer 上未设置不透明度,则一切正常。再说一次,FF 和 Chrome 都很好。

你怎么认为?

更新:这似乎仅限于 IE8。当 IE8 处于兼容模式(就像 IE7 一样)时,一切都很好!

但是,在标头中包含此标签:

<meta id="metaIE8IE7" http-equiv="X-UA-Compatible" content="IE=7" />

并不能修复它。

I am having a very odd opacity/hover problem in IE. Everything works in FF and Chrome.

Consider this page:

<!DOCTYPE html>
<html>
    <head>
    <title></title>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#outer").css("opacity", .7);
        });
    </script>
    <style type="text/css">
        #outer
        {
            position: absolute;
            width:600px;
            background: #111;
            z-index:2;
            overflow: hidden;
        }
        #outer div
        {
            float: left;
        }
        ul
        {
            list-style: none;
            margin: 0;
            padding: 0;
        }
        ul li 
        {
            width: auto;
            margin: 2px 4px 2px 4px;
            padding: 2px 4px 2px 4px;
            font-size: 11px;
            color: White;
        }
        ul li:hover
        {
            background: red;
            font-weight: 600;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="outer">
        <div id="one">
            <ul>
                <li>111</li>
                <li>222</li>
            </ul>
        </div>
        <div id="two">
            <ul>
                <li>333</li>
                <li>444</li>
            </ul>
        </div>
        <div id="three">
            <ul>
                <li>555</li>
                <li>666</li>
            </ul>
        </div>
    </div>
</body>
</html>

Here's the problem. The mouse-over is intermittent - you may or may not see a red background and font change in IE (7 or 8). You will always see the cursor change. If I take the background and font-weight out, I still see the cursor change. But if either the background or the font-weight are there, The cursor will still change but the background or font may or may not.

If the opacity is NOT set on #outer, everything works everywhere. Again, FF and Chrome are fine.

What do you think?

UPDATE: This semes to be restricted to IE8. When IE8 is in compatability mode (acting like IE7) all is well!

But, including this tag in header:

<meta id="metaIE8IE7" http-equiv="X-UA-Compatible" content="IE=7" />

does NOT fix it.

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

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

发布评论

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

评论(3

未央 2024-09-23 06:51:11

遇到了同样的问题并找到了解决方案(尽管我的解决方案是针对 a:hover 而不是 li:hover 并且我没有测试过)

基本上,请确保元素“has-layout”。例如,display:block 等。然后重置该元素的透明度。 -ms-过滤器:“”;

Had the same problem and found a solution (although my solution was for a:hover not an li:hover and I've not tested)

Basically, make sure element 'has-layout'. For example, display:block, etc. Then reset transparency for that element. -ms-filter: "";

瑕疵 2024-09-23 06:51:11

刚刚得到了完美的工作组合:

display: block;
zoom: 1;
opacity:0.4; /*for ie9 and other browsers */
filter: alpha(opacity=40); /*for ie older browsers*/

正如鲍勃所说,“has-layout”对于它在 ie 8 中工作至关重要。这里是“display: block;”完成工作。

just got the perfect working combination:

display: block;
zoom: 1;
opacity:0.4; /*for ie9 and other browsers */
filter: alpha(opacity=40); /*for ie older browsers*/

As Bob sayed the 'has-layout' is essential for it to work in ie 8. Here the 'display: block;' does the job.

懒猫 2024-09-23 06:51:11

对我来说更多 CSS 货物崇拜!我不知道,但是将 IE8 切换到 IE7 模式解决了这个问题。我错误地认为它在问题中不起作用。在其他浏览器中也仍然很好。

More CSS cargo-cult for me! I have no idea, but focing IE8 into IE7 mode fixed the problem. I was wrong about it not working in the question. Still good in other browsers too.

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