如何使用:IE8中的n-last-child?

时间:2014-06-05 11:48:57

标签: html css css3 internet-explorer-8

我在下面有这个CSS,但它在IE8上不起作用。我知道CSS3在IE8上不起作用。

我想尝试像div:first-child + div + div这样的东西,但它不起作用。我认为它因nth-last-child()而无效。我无法将nth-last-child()与相邻的同胞组合子(+)进行翻译。

/* one item */
div:nth-child(1):nth-last-child(1) {
width: 100%;
}

/* two items */
div:nth-child(1):nth-last-child(2),
div:nth-child(2):nth-last-child(1) {
width: 50%;
}

/* four items */
div:nth-child(1):nth-last-child(4),
div:nth-child(2):nth-last-child(3),
div:nth-child(3):nth-last-child(2),
div:nth-child(4):nth-last-child(1) {
width: 25%;
}

1 个答案:

答案 0 :(得分:1)

CSS-only解决方案不可能,您正在处理太旧的浏览器。从好的方面来说,你不需要自己的脚本,因为Selectivzr会这样做,或者是IE9.js的一体化解决方案(修复了大量其他IE错误,而不仅仅是添加新的选择器)。