Note the CSS in the code! Important Property

Source: Internet
Author: User

CSS in the!important is a very important attribute, and sometimes play a very large role, this knowledge is not very much, we look at the following article, the understanding of its comparative perception.

A few days ago, when I wrote some CSS code, I was embarrassed. Because the damn IE6 support to the CSS is so bad, I have not noticed before, because the basic things to do is based on IE, but I write for the blog CSS to support more than IE a browser, hateful is my installed Windows 7, this is the IE8 browser, I think there is no problem, but open IE6, still appear dislocation, so I decided to see IE6 what is the situation.

I wrap all the CSS blocks around the border, the result is that in IE, the distance between two Div is obviously wider than other browsers, such as you write a div of the margin property of 20px, then in IE is like 40px, which is why the original accuracy of the calculation is just good, In IE but the cause of dislocation.

Later I saw!important this attribute, this attribute is actually also the CSS specification, the result IE6 Leng does not support, also is because it does not support, only then lets many csser have found the solution method. In general, in CSS, if you write down two identical attributes in the same CSS block, you actually follow the bottom of the list, such as:

.home{
margin-left:20px;
margin-left:40px;
}

Then in the execution of the time is in fact according to 40px to perform,!important is to let the user set the priority of the executed statement. If you change the above statement to read:

.home{
margin-left:20px!important;
margin-left:40px;
}

Then in Firefox, Google Browser and IE7 above version will be performed according to 20px, but still in the IE6 under 40px to perform, because IE6 does not support the!important specification, we can follow this rule to meet the IE6 design needs, When found that IE6 and other browsers display different effects, then set two, in the above one to add!important tag, and the following sentence does not need to add, so IE6 follow the following to execute. Senior Csser said: "Today's CSS everywhere!important." This is the IE6 of the day to kill, everyone said IE6 is a lump of metabolites is not too.

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.