Sunday 06th of July 2008 01:21:55 PM

center a FIXED BOX

This BOX has a fixed width.
It is centered and adjusts to the browser window.
The height adjusts to the content.
more nice and free css templates

body {
background-color: #e1ddd9;
font-size: 12px;
color:#564b47;
padding:20px;
margin:0px;
text-align: center;
}
#inhalt {
text-align: left;
vertical-align: middle;
margin: 0px auto;
padding: 0px;
width: 550px;
background-color: #ffffff;
border: 1px dashed #564b47;
do not collapse. If you float an image with 20-pixel margins, therewill be at least 20 pixels of space around that image. If otherelements adjacent to the image -- and that means adjacenthorizontally and vertically -- also havemargins, those margins will not collapse with the margins on thefloated image, as we can see in Figure 7-65:

P IMG {float: right; margin: 20px;}
Figure 7-65

Figure 7-65. Floating images with margins

(To resurrect the old paper-and-plastic analogy, the plastic margins }

WARNING

Percentage values refer to the width of the parent element.

These properties operate as you'd expect by now. For example, the following two rules will give the same amount of padding:

.navbar {background: green; padding: 0; margin: 0 0 10px 0; width: 100%;}

Now everything should be set for the navigation bar, as we can see inFigure 11-4. All we need to do now is make sure themain display has some blank space to its left, and we're done.

Figure 11-4

Figure 11-4. The greening of the navigational bar

No doubt you already know how this will work. We create anotherdivision, this one classed as main and enclosingeverything in the main part of the page that isn't thenavigation bar. Then we declare: