) Record common CSS hack statements in browsers

Source: Internet
Author: User

Original address: http://www.bluebirdsky.cn/article.asp? Id = 295

I. general differentiation methods:

Ie can recognize *, but standard browsers (such as ff) cannot recognize *;
IE6 can recognize *, but cannot recognize it! Important;
IE7 can recognize * and can also recognize! Important;
IE8 can recognize/0, cannot recognize *, +, _, * +! Important;
FF cannot recognize *, but can recognize it! Important;
For example, style = "* width: 10px! Important; width: 20px; ", which is 10 Px in IE6 and 20 Px in IE7

There are three other methods:

First

 
Width: 100px;/* Firefox and other browsers */width: 200px/0;/* IE8 recognizable/0 */* width: 300px! Important;/*, IE7 can recognize both * and * width: 400px;/* IE6 can also recognize * Number * // * tip: please pay attention to the Order */

Second

 
Width: 100px;/* Firefox and other browsers */width: 200px/0;/* IE8 recognizable/0 */* width: 300px; /* IE7 can also recognize */_ width: 400px;/* IE6 can recognize the underline * // * tip: please pay attention to the Order */

Third

 
Width: 100px;/* Firefox and other browsers */width: 200px/0;/* IE8 recognizable/0 */+ width: 300px; /* + only IE7 */_ width: 400px;/* IE6 can recognize underlines * // * tip: please pay attention to the Order */
Ii. Uncommon hack (OP indicates opera, sa indicates Safari), of which 3rd are more practical
. Color1 {color: # f00; color/*/**/: # 00f/*/**/}/* IE6, IE7, IE8, FF, op, sa recognition */. color2 {color: # f00; color/*/**/: #00f/*/9 **/}/* IE7, IE8, FF, op, sa recognition */. color3 {color: # f00; color/*/**/: # 00f/9}/* IE6, IE7, IE8 recognition */. color4 {color: # f00; color/*/**/: # 00f/9}/* IE7, IE8 identifies a space between * // * "color" and */
3. Hack supported by various browsers
 
Width: 100px/0;/* supports IE8 */_ width: 100px;/* supports IE6 */[width: 100px;/* supports IE6, 7 */+ width: 100px;/* supports IE6, 7 */* width: 100px;/* supports IE6, 7 */* width: 100px! Important;/* supports IE6, 7, */* + width: 100px;/* supports IE6, 7, */* + width: 100px! Important;/* supports IE6, 7, */width: 100px/9;/* supports IE6, 7,8 */width: 100px! Important;/* supports IE6, 7,8, FF */W/idth: 100px;/* ie5.x does not support IE6, IE7, IE8, and FF */
Iv. Conditional annotation function exclusive to IE

1. Only visible to IE

 
<! -- [If IE]> the content here is only visible to IE <! [Endif]->

2. Only IE6 visible Writing Method

 
<! -[If IE 6.0]> the content here is only visible to ie6.0 <! [Endif]->

3. Only IE7 visible Writing Method

 
<! -[If ie 7.0]> the content here is only visible to ie7.0 <! [Endif]->

4. Display format of version ranges

 
<! -- [If lt IE 6]> versions earlier than IE6 and IE6 are recognizable <! [Endif] --> <! -- [If gte ie 6]> IE6 and IE6 and later versions can be recognized <! [Endif] --> <! -- [If lt IE 7]> versions earlier than IE7 and IE7 are recognizable <! [Endif] --> <! -- [If gte ie 7]> IE7 and IE7 versions can be identified <! [Endif] -->

5. Non-ie visible writing (Note: This article does not comply with web standards, but is indeed practical)

 
<! -- [If! IE]> the content here is not visible to ie Only <! [Endif] -->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.