2011年7月26日 星期二

IE的if條件Hack

IE的if條件Hack
IE的if條件Hack可以讓IE區別於其它流覽器和IE個版本之間的流覽器,它利用<!--[if IE]>...<![endif]-->這樣的語法讓IE流覽器對齊進行解析,屬於IE專有。


<!--[if IE]> Only IE <![endif]-->

所有的IE可識別

<!--[if IE 5.0]> Only IE 5.0 <![endif]-->

只有IE5.0可以識別

<!--[if gt IE 5.0]> Only IE 5.0+ <![endif]-->

IE5.0包換IE5.5都可以識別

<!--[if lt IE 6]> Only IE 6- <![endif]-->

僅IE6可識別

<!--[if gte IE 6]> Only IE 6/+ <![endif]-->

IE6以及IE6以下的IE5.x都可識別

<!--[if lte IE 7]> Only IE 7/- <![endif]-->

僅IE7可識別



<!--[if IE]>...<![endif]-->之間內容的具體用法:
<!--[if IE 7]> <link rel="stylesheet" href="../css/ie7.css" type="text/css" media="screen" /><![endif]-->

可以像這樣連結一個CSS檔



<!--[if IE]>

<style>

.clearfix {display: inline-block;}

</style>

<![endif]-->

也可以像這樣直接輸入一行CSS代碼

沒有留言:

張貼留言