在IE 8中,nth-of-type在媒体查询中不起作用

时间:2013-12-31 07:51:38

标签: javascript css3

nth-of-type在媒体查询中不起作用,但在IE 8中的同一css文件中在媒体查询之外工作。 我正在使用

<script src="http://css3-mediaqueries-js.googlecode.com/files/css3-mediaqueries.js" ></script>

和css:

.j-container:nth-of-type(1), .j-container:nth-of-type(3) {
    background-color: #eee;
}/* It is working */
@media screen and (max-width: 480px) {

.j-container:nth-of-type(1), .j-container:nth-of-type(3) {
    background-color: #ff0000;
}/* Not working */
@media screen and (max-width: 768px) {

.j-container:nth-of-type(1), .j-container:nth-of-type(3) {
    background-color: #ff0000;
}/* Not working */
@media screen and (man-width: 769px) {

.j-container:nth-of-type(1), .j-container:nth-of-type(3) {
    background-color: #ff0000;
}/* Not working */

1 个答案:

答案 0 :(得分:0)

IE8不支持很多像nth这样的CSS3选择器,IE8也不支持媒体查询:

http://caniuse.com/#search=media%20queries

此外,您的媒体查询未关闭,无法提供帮助。

您在所有媒体查询中选择第一个和第三个类型,以便您可以使用普通类来改变背景颜色?

如果你想在IE8中使用它,你需要使用polyfill进行媒体查询和CSS3选择器,这里有一个很好的列表供你观看:

https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills