IE8中最小宽度的奇怪行为

时间:2011-10-12 06:55:12

标签: html css html5 css3 media-queries

我有一个简单的要求; 将desktop.css应用于更大的屏幕尺寸和 将iPad.css应用于更小的屏幕尺寸

现在我想使用CSS Media Queries。

<link rel="stylesheet" media="only screen and (min-width: 768px)" href="css\desktop.css">
<link rel="stylesheet" media="only screen and (max-width: 768px)" href="css\ipad.css">

现在我已经读过旧的IE不支持min-width。但是我在IE8中看到了一种奇怪的支持 即IE8将min-width识别为属性,但不将其视为媒体查询。

所以

  

#example{*min-width:100px;}

在IE8中工作正常

但这不是

@media only screen and (min-width:100px) 

我已经为IE

尝试了以下内容
<!--[if IE ]><link rel="stylesheet" media="screen" href="css\desktop.css"><![endif]-->

但是我想只在特定的最小宽度上应用IE桌面css,而不是总是......

是否有针对此的JS解决方法;

<!--[if IE AND min-width:100px]><link rel...

请告诉我如何在IE中应用2套CSS。

1 个答案:

答案 0 :(得分:4)

Media queries are only supported by IE9+. 您可以使用像Respond.js这样的polyfill来兼容IE6-8。

相关问题