简体   繁体   English

CSS悬停在IE8中不起作用

[英]CSS Hover doesn't work in IE8

I have an DNN web site which use's the following code for the menu dropdown. 我有一个DNN网站,其菜单下拉菜单使用以下代码。

IE8 doesn't like it and the sub menu won't pull down. IE8不喜欢它,并且子菜单不会下拉。

.nav-collapse:not(.in) .nav li:hover > ul {
    display: block;
}

You can duplicate this by going to http://dnnsample.azurewebsites.net in IE8. 您可以通过访问IE8中的http://dnnsample.azurewebsites.net复制此内容。 The About Us has a submenu. 关于我们有一个子菜单。 If you have IE11 you can press F12 > press ctrl+8 and change document mode to 8. 如果您使用的是IE11,则可以按F12>按ctrl + 8并将文档模式更改为8。

Anyone know an alternate method of making this work in IE8? 有人知道在IE8中实现此功能的另一种方法吗?

The :not CSS3 selector isn't supported in IE8. IE8不支持:not CSS3选择器。

Try to select your element with using :not and your hover will work just fine. 尝试使用:not选择您的元素,您的鼠标悬停就可以了。

http://caniuse.com/css-sel3 http://caniuse.com/css-sel3

You could use two CSS rules. 您可以使用两个CSS规则。 The second one should override the first but only for elements with the .in class. 第二个应覆盖第一个,但仅适用于具有.in类的元素。 It should have the same effect as your selector using :not() . 它应该与使用:not()选择器具有相同的效果。

.nav-collapse .nav li:hover > ul {
    display: block;
}

.nav-collapse.in .nav li:hover > ul {
    display: none; // or whatever display value you have as default
}

The reason your CSS isn't working is because :not() is only supported by IE9+. CSS不起作用的原因是:not()仅受IE9 +支持。 See this MDN article for reference 请参阅此MDN文章以供参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM