li:last-child doesn't seem to work in IE8

前端 未结 7 1985
别那么骄傲
别那么骄傲 2021-01-20 05:54

Below is my html structure

  • Home
  • About
  • Feedb
7条回答
  •  猫巷女王i
    2021-01-20 06:50

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

    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 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.

    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
    

提交回复
热议问题