li:last-child似乎在IE8中不工作 [英] li:last-child doesn't seem to work in IE8

查看:695
本文介绍了li:last-child似乎在IE8中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的html结构

Below is my html structure

<div class="footerMenu">
   <ul>
     <li>Home</li>
     <li>About</li>
     <li>Feedback</li>
     <li>Contact us</li>        
   </ul>            
</div>

.footerMenu li:last-child { } 

IE8。但是 http://msdn.microsoft.com/en- us / library / cc351024%28VS.85%29.aspx 告诉伪选择器被支持。对此有任何帮助!

selector doesn't seem to work in IE8. But http://msdn.microsoft.com/en-us/library/cc351024%28VS.85%29.aspx tells that the pseudo-selector is suppported.Any help on this!

推荐答案

你读错了。它表示在IE8中支持:

You read it wrong. It says that it's not supported in IE8:

如果您正在查看:first-child IE7和IE8,并认为同样适用于:last-child ...惊喜!它不是。

If you were looking at :first-child, which does have support in IE7 and IE8, and thinking that the same applies to :last-child... surprise! It doesn't.

:first-child 是一个CSS2选择器,但: last-child 只是在CSS3中引入的,所以由于Microsoft只针对CSS2.1兼容IE8,他们可能没有关心:last-child 直到post-IE8。

:first-child is a CSS2 selector, but :last-child was only introduced in CSS3, so since Microsoft was only aiming for CSS2.1 compliance with IE8, they likely didn't bother about :last-child until post-IE8.

如果你知道你只有四个 li 应该能够使用相邻的兄弟选择器到达第四个 li

If you know you will only have four li elements, then you should be able to use adjacent sibling selectors to reach the fourth li:

.footerMenu li:first-child + li + li + li

这篇关于li:last-child似乎在IE8中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆