Css hack in-depth analysis

Source: Internet
Author: User

What is CSS hack?

Different browsers, such as Internet Explorer 6, Internet Explorer 7, and Mozilla Firefox, have different understandings of CSS parsing, which leads to different page effects, we cannot get the page effect we need.

At this time, we need to write different CSS for different browsers so that they can be compatible with different browsers at the same time, so that we can get the desired page effect in different browsers.
This process of writing different CSS codes for different browsers is called CSS hack, also called CSS hack.

What is the principle of CSS Hack?

Because different browsers have different support for CSS and parse results, they also have a relationship with the priority of CSS. We can write different CSS for different browsers based on this.
For example, IE6 can recognize underscores (_) and star numbers (*). IE7 can recognize asterisks (*) but cannot recognize underscores (_). firefox cannot recognize both of them. And so on.
The writing order is generally to write the CSS of a browser with strong recognition ability behind. The following describes how to write more details.

How to Write CSS Hack?

For example, to distinguish IE6 from firefox, you can write as follows:

<style> div{   background:green; /* for firefox */   *background:red; /* for IE6 */ } </style>

The result is red in IE6 and green in firefox.

Articles you may be interested in
  • CSS intercepts strings to automatically add ellipsis
  • CSS adds a background image to the text input box
  • Php Output Control: understanding the differences between ob_flush and flush
  • Div css book tutorials recommend "professional CSS + DIV webpage style and layout video tutorials"
  • Code used to test the password strength of a user input using Javascript
  • Javascript restricts that only numbers (including decimal places) can be entered in the text box)
  • Jquery $. ajax $. post or $. get: How to submit the checkbox Value
  • Mysql having and group by statement usage

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.