在IE7中悬停时菜单抖动。 HasLayout问题?

时间:2011-11-03 17:39:50

标签: javascript css haslayout

当我在IE7中测试时,菜单会在第一次鼠标悬停时抖动,并稍微改变位置。此外,当将鼠标悬停在包含子菜单的菜单项上时,菜单会再次抖动。我认为这两个问题都与IE7 hasLayout有关,但我不确定。

JSFiddle

有没有办法在我的菜单和子菜单标签上确保IE7的css中的hasLayout?或者,是否在IE7中以某种方式插入了文本节点?谢谢你的帮助。

1 个答案:

答案 0 :(得分:1)

确实你是对的。似乎是hasLayout issue with IE7

我更改了CSS属性。

#nav {
    margin: 70px 0px 0px -15px;
    padding: 0px;
    list-style: none;
    font-size: 14px;
    position: relative;
}

#nav li a {
    display: inline-block; /* changed it to inline-block for IE compatibility */
    width: 195px; /* declared width since it's now inline-block */
    padding: 0 0 0 15px; /* total width 210px with padding */
    text-decoration: none;
    line-height:20px; /* vertical center with line-height instead */
    color: #262626;
    height: 20px;
}

.subnav {
    margin: -26px 0 0 ;
    padding: 0;
    list-style: none;
    position: absolute;
    display: none;
    left:196px;
    background: #201d1e;
    width: 325px;
}

/* same idea as (#nav li a) */
.subnav a {
    display: inline-block;
    color: #fff !important;
    padding: 0 0 0 15px;
    width: 310px;
    line-height:20px;
    height: 20px;
}

子菜单比现代浏览器渲染了几个像素,但是.subnav上的-26px可以使用IE7样式表进行调整。我认为它接近margin-top:对于IE7来说是-10px。希望这会成功。

http://jsfiddle.net/marioluevanos/VAuYx/11/