This is an article about CSS hack, this article refers to the CSS hack is for class, id the attributes of the hack, the order of arrangement are required. Today to talk to you about class, id do CSS HACK.
Copy Code code 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;
}
The above CSS code can see that FF is still the most obedient browser, in IE6 and IE7 if you want to use hack must be preceded by the addition of the Kraft tag HTML. Here is a good memory, IE6 plus *html, and IE7 plus *+html, hint added a version. The advantage of CSS hack by class, ID is that it does not have to take into account the sequence, and is easy for management and other people to accept, but also through this hack similar to the JS browser version of the control. The disadvantage is probably to produce a lot of code! Well, let's talk about that roughly.
Read above can click on the effect of the following in different browsers to see the effect, where the Orange representative FF, blue for IE7, black for IE6.
<textarea id="runcode77369"><! 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=" Tex t/html; Charset=utf-8 "/> <title> cloud-dwelling community www.jb51.net CSS hack</title> <style type=" text/css "> *{ma rgin: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> <div class= "test" ></div> <body> </body> </HTML&G T </textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]