Yes! Important solves the layout difference between IE and Mozilla
Source: Internet
Author: User
When designing the webpage designer page, there was a problem that had plagued me all the time. The main menu showed a 2px effect deviation in IE and other browsers (Mozilla, Opera, etc. The screenshot is as follows:
Effect in IE
Effects in Mozilla Firefox
This is because of the bug in IE's interpretation of the distance between boxes (refer to onestab's "floating model problem "). I have never solved this problem until I translate "table showdown CSS-a battle of life and death", the author's tips help me find a solution: Use! Important.
! Important is a syntax defined in CSS1 to improve the application priority of a specified style rule (see the W3.org interpretation ). Syntax format {sRule! Important} is written at the end of the definition, for example: box {color: red! Important ;}
The most important thing is that IE does not support this syntax all the time, but other browsers do. Therefore, we can use this to define different styles for IE and other browsers. For example, we define a style:. colortest {
Border: 20px solid #60A179! Important;
Border: 20px solid # 00F;
Padding: 30px;
Width: 300px;
}
It can be understood when browsing in Mozilla! Important priority, so the color of #60A179 is displayed:
Cannot be understood when browsing in IE! Important priority, so the color of # 00F is displayed:
You can see, use! Important, we can set different styles for IE and non-IE browsers, as long as it is added after the style of the non-IE browser! Important. Therefore, the 2px display difference on my homepage mentioned above can be easily solved:
PADDING-TOP: 11px! Important;
PADDING-TOP: 9px;
! Important must be a powerful CSS Layout Tool. Please remember and master it :)
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.