HTML and CSS Reference
In-Depth Information
Using Negative Margins
Margins can be a negative length as well as positive. Negative margins
are an often overlooked but extremely useful device for manipulating the
space between elements or for escaping the confines of the content area
of a containing element.
The first example ( Figure 5.3 ) overlaps two sibling elements by using a
negative top margin.
Figure 5.3
Negative top
margin causing
elements to
overlay.
header {
background: #999;
padding-bottom: 2em;
}
article {
border: 1px solid #999;
background: #fff;
margin: 1em 2em;
}
header+article {
margin-top: -1em;
}
[...]
<header>
 
 
Search WWH ::




Custom Search