這篇文章主要介紹了關(guān)于HTML條件注釋用法詮釋 ,有著一定的參考價(jià)值,現(xiàn)在分享給大家,有需要的朋友可以參考一下
注釋內(nèi)容以樣式為例,如下:
<!--[if IE]> <link rel="stylesheet" href="all-ie-only.css" type="text/css"/> <![endif]-->
<!--[if !IE]> <link rel="stylesheet" href="not-ie.css" type="text/css"/> <![endif]-->
上面是除了IE瀏覽器外所有瀏覽器都識別這個(gè)樣式,另外CSS-TRICKS的《How To Create an IE-Only Stylesheet》一文中提供了另一種寫法:
<!--[if !IE]><!--><link rel="stylesheet" type="text/css" href="not-ie.css" /><!--<![endif]-->
<!--[if IE 10]> <link rel="stylesheet" type="text/css" href="ie10.css"> <![endif]-->
這種方法是樣式表使用在低于IE10的瀏覽器,換句話說除了IE10以外的所有IE版本都將被支持。
<!--[if lt IE 10]> <link rel="stylesheet" type="text/css" href="ie9-and-down.css"> <![endif]-->
也可以寫成
<!--[if lte IE 9]> <link rel="stylesheet" type="text/css" href="ie9-and-down.css"> <![endif]-->
前面我們也說過了lt和lte的區(qū)別,lt表示小于版本號,不包括條件版本號本身;而lte是小于或等于版本號,包括了版本號自身
。
上面這幾種方法,使用的是低于(lt)和低于或等于(lte)的方法來判斷,我們也可以使用大于gt
和大于或等于gte
達(dá)到上面的效果:
<!--[if gt IE 9]> <link rel="stylesheet" type="text/css" href="ie10-and-up.css"> <![endif]-->
或
<!--[if gte IE 10]> <link rel="stylesheet" type="text/css" href="ie10-and-up.css"> <![endif]-->
<!--[if (IE 6)|(IE 7)|(IE 8)]> <link rel="stylesheet" type="text/css" href="ie6-7-8.css"> <![endif]-->
參考:
https://www.cnblogs.com/hushufang/p/3708704.html
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com