【问题标题】:Weird IE9 Bug with UL and hovered images in CSS带有 UL 的奇怪 IE9 错误和 CSS 中的悬停图像
【发布时间】:2011-07-19 17:26:58
【问题描述】:

我正在努力在页面右侧制作一个简单的导航框。我基本上在 UL 中有五个图像链接,它们在 CSS 中有一个悬停属性,用于设置背景位置,因此有悬停效果。

它在 Firefox、Safari、Chrome 和 IE7 中运行良好。但是,启动 IE9 并且所有图像都有额外的垂直边距间距或低于它们约 1 像素的东西,当您悬停时,展示位置会关闭 1 像素或 2 像素。

首先,我通过以下方式禁用了自动 IE9 兼容性视图:

<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9" />

由于某种原因,IE9 打开了兼容性视图,这弄乱了我的元素浮动。

这是我的 HTML:

<div id="right">
    <ul id="greenpractices">
        <li id="rightmission_water"><a href="water.html">Water</a></li>
        <li id="rightmission_air"><a href="air.html">Air</a></li>
        <li id="rightmission_innovation"><a href="innovation.html">Innovation</a></li>
        <li id="rightmission_energy"><a href="energy.html">Energy</a></li>
        <li id="rightmission_design"><a href="design.html">Design</a></li>
    </ul>
</div>

还有 CSS:

#right {
float: left;
display: inline;
width: 286px;
border-top: 1px solid #686868;
padding: 17px 16px 0px 17px;
}

ul#greenpractices {
list-style-position: outside;
list-style-type: none;
width: 286px;
height: 260px;
}

ul#greenpractices li, ul#greenpractices li a, ul#greenpractices li a:active, ul#greenpractices li a:visited {
position: relative;
display: block;
width: 286px;
height: 52px;
text-indent: -99999px;
}

ul#greenpractices li a:hover {
background-position: 0 0;
}

li#rightinnovation_innovation a {
background: url('images/rightinnovation_innovation.jpg') bottom;
}

li#rightinnovation_air a {
background: url('images/rightinnovation_air.jpg') bottom;
}

li#rightinnovation_water a {
background: url('images/rightinnovation_water.jpg') bottom;
}

li#rightinnovation_energy a {
background: url('images/rightinnovation_energy.jpg') bottom;
}

li#rightinnovation_design a {
background: url('images/rightinnovation_design.jpg') bottom;
}

非常感谢任何可以提供帮助的人!

【问题讨论】:

  • 别找你了。在 Windows 7 上的 IE9 和 FF5.01 看起来完全一样?
  • 看到右边的导航框了吗?图像在垂直之间有边距,当您悬停时会移动。我只希望图像上的文字在您悬停时变亮。
  • 我看到 IE9 和 Chrome 之间没有任何变化,当我将鼠标悬停在 IE 中时,它没有显示任何不同。您可能希望将背景图像和悬停更改为 li 元素而不是锚标记。有时锚标签上的样式并不能像您期望的那样工作。
  • 感谢您的提示。会不会是我用的电脑?有关问题的添加屏幕截图,请参见上文。

标签: css image hover internet-explorer-9


【解决方案1】:

最后发现我使用的 IE9 窗口放大了 105%。刚好够不引人注意。感谢所有提供帮助的人 - 这很令人沮丧!

【讨论】:

    猜你喜欢
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 2012-08-07
    • 2011-10-11
    • 2011-05-14
    • 2013-04-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多