针对差别的IE浏览器版本,运用if前提来设置对应css技俩,从而规划css hack
<!--[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可识别以内的css格局
<!--[if gte IE 6]> Only IE 6/+ <![endif]-->
IE6以及IE6以下的IE5.x都可辨认
<!--[if lte IE 7]> Only IE 7/- <![endif]-->
仅IE7可辨认之内的css技俩
额外阐明ie8不克不及运用if前提来设置div css花样,这里的“<!-”是css注解、css注释、css表述顶用到雷同,笼统进入明了css 注释。这里使用css注释方式来筹算if条件潜藏前提,从而在其它不相符if条件阅读器下不表现前提及批注if前提里花样,你可以了解下css窜伏此外办法。
经由以上的if条件来对差异版本浏览器调用分歧css格式来图谋css hack门径。
实比喻下:
日后我们只履行一个只要微软IE可辨认,火狐不辨认例子代码以下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>IE的if条件css hack实例</title> <style type="text/css"> <!--[if IE]> <!-- .ys1 {color: #FF0000} --> <![endif]--> </style> </head>
<body> |
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/shili/s52144.shtml