2019-07-03 21:33:15 在html静态网页中,也是支持if 注释的,html注释用if可以条件判断不同浏览器显示不同代码内容,包括用if注释调用不同外部css文件。
在html静态网页中,也是支持if 注释的,html注释用if可以条件判断不同浏览器显示不同代码内容,包括用if注释调用不同外部css文件。
HTML if 注释代码:
<!--[if lte IE 6]>
<link rel="stylesheet" media="all" type="text/css" href="style.css" />
<![endif]-->
用if判断IE6及以下版本浏览器来读取style.css文件。
通过判断IE版本来调用不同外部CSS文件。
<!--[if IE 7]>
我IE7显示
<!--<![endif]-->
如果是IE7,内容“我IE7显示”将被显示。
更多html if判断浏览器版本代码:
<!--[if !IE]> 除IE外都可识别 <![endif]-->
<!--[if IE]> 所有的IE可识别 <![endif]-->
<!--[if IE 6]> 仅IE6可识别 <![endif]-->
<!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]-->
<!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
<!--[if IE 7]> 仅IE7可识别 <![endif]-->
<!--[if lt IE 7]> IE7以及IE7以下版本可识别 <![endif]-->
<!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->
<!--[if IE 8]> 仅IE8可识别 <![endif]-->
<!--[if IE 9]> 仅IE9可识别 <![endif]-->
更多注释运算符号解释:
lte:是Less than or equal to的简写,也就是小于或等于的意思。
lt :是Less than的简写,也就是小于的意思。
gte:是Greater than or equal to的简写,也就是大于或等于的意思。
gt :是Greater than的简写,也就是大于的意思。