Negative margin usage notes: negative margin usage Problems
Negative margin is often used in project strength, for example:
<Div id = "test"> <ul> <li> child element 1 </li> <li> child element 2 </li> <li> child element 3 </li> <li> child element 4 </li> <li> child element 5 </li> <li> child element 6 </li> </ul> </div>
Is the implementation effect:
To ensure css compatibility with ie 6, you need to add a style to the floating li inclusion layer ul.
position: relative;zoom: 1;
At this time, ul should not use clearfix to clear the floating head, ie6 will fail.
Negative value of CSS margin-top
The negative value of margin, called the negative outer patch, can be negative in all four directions, that is, to narrow the periphery of the container. Usually used with position.
For example, a horizontal absolute center is used.
# Box {width: 960px; height: 50px; margin-left:-480px; padding: 0; position: absolute; left: 50%; top: 0; z-index: 16 ;}
Here we use margin-left:-480px;, which is the half width of the container and is absolutely centered.
Of course, there are still a lot of negative patch usage, You can google.
It has nothing to do with compatibility. It depends on you to adjust your css code to achieve compatibility.
Ask a question about the use of margin in CSS
If a value is directly added after margin, it is in the order of left, top, right, and bottom.
So margin: 0-170px 0 0 is equivalent
Margin-left: 0px;
Margin-top:-170px;
Margin-right: 0px;
Margin-bottom: 0px;
If the value is 0, no unit is allowed.