Special Beef FF/IE6/IE7 Dedicated CSS Hack_ experience exchange

Source: Internet
Author: User
This is an article about CSS hack, the CSS hack mentioned in this article is for the class, the ID of the attribute hack, the order of arrangement has requirements. Today we are talking about the CSS HACK for class and ID.
Copy CodeThe code is as follows:

. test{/*ff*/
height:20px;
Background-color:orange;
}
*+html. test{/*ie7*/
height:20px;
Background-color:blue;
}
*html. test{/*ie6*/
height:20px;
Background-color:black;
}



Through the above CSS code can be seen FF or the most obedient browser, in IE6 and IE7 if you want to use hack must be preceded by the husband-level tag HTML. Here is very good memory, IE6 plus *html, and IE7 plus *+html, hinted added a version. The advantage of CSS hack for class and ID is that it does not have to take into account the sequence, and it is easy for management and other people to accept, and this kind of hack can realize the control like JS browser version. The downside is that it could be a lot of code! All right, let's talk about this.

The above content can click on the following effect in different browsers to see the effect, where orange for FF, blue for IE7, black for IE6.
<textarea id="runcode55086"><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> scripting House www.jb51.net CSS hack</title> <style type=" Text/css "> *{margin:0; padding:0; }. test{/*ff*/height:20px; Background-color:orange; } *+html. test{/*ie7*/height:20px; Background-color:blue; } *html. test{/*ie6*/height:20px; Background-color:black; } </style> </pead> <body> </body> </ptml></textarea>
[Ctrl + A full selection Note: If you need to introduce external JS need to refresh to execute]
  • Related Article

    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.