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

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

Below is my html structure

  • Home
  • About
  • Feedb
相关标签:
7条回答
  • 2021-01-20 06:28

    To build on the other guys answers, an alternative could be to use javascript to fill the gaps, selectivizr is a good example of adding last-child support.

    http://selectivizr.com/

    0 讨论(0)
  • 2021-01-20 06:35

    Where did you read that? :first-child is supported back to IE7, but :last-child is IE9 and later.

    No, it doesn't.

    (Headers moved down for your convenience)

    0 讨论(0)
  • 2021-01-20 06:38

    I know its old but...there is a simple way to do it:

    Just in the li you want the change do this:

    <li style="yourstyle;">...</li>

    0 讨论(0)
  • 2021-01-20 06:40

    Try to use something like that:

    .footerMenu li {background-color: expression(this.previousSibling==null?'red':'green');}
    
    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2021-01-20 06:53

    The link you provided shows that it isn't supported for IE8... IE9+ only. Googling last-child IE8 brings up a whole host of similar queries.

    0 讨论(0)
提交回复
热议问题