:last-child pseudo class selector in CSS and Internet Explorer

前端 未结 4 615
天命终不由人
天命终不由人 2020-12-09 23:05

I have the following code:

ul.myList li{
     border-right: 1px dotted #000;
}

However, on the last element, I need to remove that border a

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 23:13

    So, after some digging around, I found the answer:

    If the browser is IE<8, specify a stylesheet like this:

    
    

    And within your IE stylesheet specify the following rules:

    ul.myList li{
         border-right: expression(this.nextSibling==null?'none':'inherit');
    }
    

    The nextSibling expression looks to see if there is an element after it and if there is inherits the rule specified in the default stylesheet, if not it applys a new rule.

    More information can be found here

提交回复
热议问题