IE 8不支持n-child如何解决这个问题?

时间:2014-01-22 09:47:37

标签: css css3

IE 8不支持n-child如何解决这个问题?

 #hm-top div:nth-child(1) h3 {
    color: #63c2ff;
    width: 300px;
    padding: 115px 0 0 0;
    background: url(images/trade.png) no-repeat center top;
    }

3 个答案:

答案 0 :(得分:5)

IE8支持:first-child,相当于:nth-child(1)

#hm-top div:first-child h3 {
    color: #63c2ff;
    width: 300px;
    padding: 115px 0 0 0;
    background: url(images/trade.png) no-repeat center top;
}

答案 1 :(得分:2)

equivalent to li:nth-child(1)
li:first-child { /* change to this */
    border-top: 5px solid red;
}
equivalent to li:nth-child(2)
li:first-child + li { /* change to this */
    border-top: 5px solid blue;
}
equivalent to li:nth-child(3)
 li:first-child + li + li { /* change to this */
    border-top: 5px solid green;
}​

答案 2 :(得分:0)

使用jQuery修复它。像这样:

$('#hm-top div:nth-child(1) h3').addClass('ie8-nth-fix');

在你的CSS中

#hm-top div:nth-child(1) h3, .ie8-nth-fix {
   color: #63c2ff;
   width: 300px;
   padding: 115px 0 0 0;
   background: url(images/trade.png) no-repeat center top;
}