欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

IE條件語句 IE hack大全

 更新時間:2012年05月23日 19:17:04   作者:  
條件注釋只有在IE瀏覽器被支持,因此僅適用于IE的特殊指令。從IE5起都支持
Conditional comments work as follows:
復制代碼 代碼如下:

<!--[if IE 6]>Special instructions for IE 6 here<![endif]-->
[code]

Their basic structure is the same as an HTML comment (<!-- -->). Therefore all other browsers will see them as normal comments and will ignore them entirely.
IE, though, has been programmed to recognize the special <!--[if IE]> syntax, resolves the ifand parses the content of the conditional comment as if it were normal page content.
Since conditional comments use the HTML comment structure, they can only be included in HTML files, and not in CSS files. I'd have preferred to put the special styles in the CSS file, but that's impossible. You can also put an entire new <link> tag in the conditional comment referring to an extra style sheet.
Example
Below I added a lot of conditional comments that print out messages according to your IE version.

Note however, that if you use multiple Explorers on one computer, the conditional comments will render as if all these Explorer versions are the highest Explorer version available on your machine (usually Explorer 6.0).

Test
Below are a few conditional comments that reveal the IE version you're using.

According to the conditional comment this is IE
According to the conditional comment this is IE 7
According to the conditional comment this is IE lower than 9
According to the conditional comment this is IE lower or equal to 7
According to the conditional comment this is IE greater than 6

Code
The syntax I use is:
[code]
<p class="accent">
<!--[if IE]>
According to the conditional comment this is IE<br />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is IE 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is IE 7<br />
<![endif]-->
<!--[if IE 8]>
According to the conditional comment this is IE 8<br />
<![endif]-->
<!--[if IE 9]>
According to the conditional comment this is IE 9<br />
<![endif]-->
<!--[if gte IE 8]>
According to the conditional comment this is IE 8 or higher<br />
<![endif]-->
<!--[if lt IE 9]>
According to the conditional comment this is IE lower than 9<br />
<![endif]-->
<!--[if lte IE 7]>
According to the conditional comment this is IE lower or equal to 7<br />
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is IE greater than 6<br />
<![endif]-->
<!--[if !IE]> -->
According to the conditional comment this is not IE<br />
<!-- <![endif]-->
</p>

Note the special syntax:

gt: greater than
lte: less than or equal to
Also note the last one. It has a different syntax, and its contents are shown in all browsers that are not IE:
復制代碼 代碼如下:

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


CSS hack?
Are conditional comments CSS hacks? Strictly speaking, yes, since they can serve to give special style instructions to some browsers. However, they do not rely on one browser bug to solve another one, as all true CSS hacks do. Besides, they can be used for more than CSS hacks only (though that rarely happens).

Since conditional comments are not based on a browser hack but on a deliberate feature I believe they are safe to use. Sure, other browsers could implement conditional comments, too (though as yet none have done so), but they're unlikely to react to the specific query <!--[if IE]>.

I use conditional comments, though sparingly. First I see if I can find a real CSS solution to an Explorer Windows problem. If I can't, though, I don't hesitate to use them.

Comment tag
A reader told me IE also supports the (non-standard) <comment> tag.

<p>This is <comment>not</comment> IE.</p>

This isIE.

This tag might be a replacement for the !IE conditional comment.

相關文章

  • Iris 環(huán)境搭建詳細教程(最新版Go&IDEA&IrisV12)

    Iris 環(huán)境搭建詳細教程(最新版Go&IDEA&IrisV12)

    這篇文章主要介紹了Iris 環(huán)境搭建(最新版Go&IDEA&IrisV12),本文通過示例圖文相結合給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-11-11
  • Loongnix安裝PyCharm Community 2020.2.3的教程詳解

    Loongnix安裝PyCharm Community 2020.2.3的教程詳解

    這篇文章主要介紹了Loongnix安裝PyCharm Community 2020.2.3的教程詳解,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-11-11
  • Django 使用 cookie 實現簡單的用戶管理功能

    Django 使用 cookie 實現簡單的用戶管理功能

    這篇文章主要介紹了Django 使用 cookie 實現簡單的用戶管理功能,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-06-06
  • 微信應用號(小程序)入門安裝教程及IDE(破解版)下載

    微信應用號(小程序)入門安裝教程及IDE(破解版)下載

    這篇文章主要介紹了微信應用號(小程序)入門安裝教程及IDE下載的相關資料,需要的朋友可以參考下
    2016-09-09
  • Windows10使用Anaconda安裝Tensorflow-gpu的教程詳解

    Windows10使用Anaconda安裝Tensorflow-gpu的教程詳解

    Anaconda是一個方便的python包管理和環(huán)境管理軟件,一般用來配置不同的項目環(huán)境。這篇文章主要介紹了Windows10使用Anaconda安裝Tensorflow-gpu的教程,本文通過圖文并茂的形式給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-02-02
  • HTTP頭信息總結

    HTTP頭信息總結

    這篇文章主要介紹了HTTP頭信息總結,HTTP的頭域包括通用頭、請求頭、響應頭和實體頭四個部分,本文羅列了40個HTTP頭信息,需要的朋友可以參考下
    2014-07-07
  • 解決Visual Studio 2019本地不能運行Azure Functions

    解決Visual Studio 2019本地不能運行Azure Functions

    本文主要介紹了Visual Studio 2019本地不能運行Azure Functions的解決方方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-06-06
  • 8種類型極品程序員,不知你屬于哪一種?

    8種類型極品程序員,不知你屬于哪一種?

    這篇文章主要介紹了8種類型極品程序員,不知你屬于哪一種?本文總結歸納了8種程類型的程序員,總結的非常精辟,來看看你是屬于哪一種吧~
    2014-09-09
  • 嘁,都2020了,你咋還在單純的使用if-else

    嘁,都2020了,你咋還在單純的使用if-else

    我們在寫程序時,常常需要指明兩條或者更多的執(zhí)行路徑,使得程序執(zhí)行時,能夠選擇其中一條路徑,去執(zhí)行相應的語句,產生對應的結果 —— 這也是條件語句在程序中的作用。下面通過例子給大家介紹下if-else的使用,感興趣的朋友一起看看吧
    2020-10-10
  • 微信小程序開發(fā)工具介紹

    微信小程序開發(fā)工具介紹

    這篇文章主要為大家介紹了微信小程序開發(fā)工具及基本的使用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步早日升職加薪
    2022-04-04

最新評論