[CSS] solves browser compatibility-CSS hack

Source: Internet
Author: User

We will inevitably encounter browser compatibility problems when making pages, especially IE6. How can we be compatible with all browsers? The answer is CSS hack.

The followingCodeIt is some common CSS hack I have compiled myself. I hope it will help you.

 <!  Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"  >     <  Html  Xmlns  = "Http://www.w3.org/1999/xhtml"  XML: Lang  = "En"  >     <  Head >         <  Meta  HTTP-equiv  = "Content-Type"  Content  = "Text/html; charsets = UTF-8"   />         <  Meta  HTTP-equiv  = "X-UA-compatible"  Content  = "Ie = emulateie7"   />         < Title  > CSS hack </  Title  >         <  Style  Type  = "Text/CSS"  >  . Demo  {  Width  :  100px ;  Height  :  100px  ;  Border  :  5px solid orange  ;  }  . Demo1  { Background  :  Black  ;     /*  For all  */         }  . Demo2  {  Background :  Green \ 9  ;   /*  For IE  */         }  . Demo3  {  Background  :  Yellow \ 0 ;      /*  For IE8  */         }  . Demo4  {  * Background  :  Blue  ;     /* For IE7, IE6  */         }  . Demo5  {  _ Background  :  Red  ;      /*  For IE6 */         }         </  Style  >     </  Head  >     <  Body  >         <  Div  Class  = "Demo demo1"  > </ Div  > <  BR  />         <  Div  Class  = "Demo demo2"  > </  Div  > <  BR  />         <  Div  Class  = "Demo demo3" > </  Div  > <  BR  />         <  Div  Class  = "Demo demo4"  > </  Div  > <  BR  />         <  Div  Class = "Demo demo5"  > </  Div  >     </  Body  >     </  Html  > 

There are also some CSS hack that I haven't used to list, such as chrome and opera. We usually cannot use these methods.

Tested browsers: IE6, IE7, IE8, ie9, Firefox, Google, Safari

PS: The best csser is compatible with all browsers without CSS hack. I also recommend that you avoid using CSS hack as much as possible. However, there is no way to deal with IE 6 (IE7), which is often entangled in 1 or 2 pixels. Otherwise, our tests won't pass, project offline --

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.