Monday 20th of November 2017 02:44:20 AM

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;
}

Example

his property defines whether or not the background image scrolls along with the element. This is generally applied to BODY only, and in fact is largely supported only for that element. It is theoretically possible to create "aligned" backgrounds in multiple elements using this property; see Chapter 6, "Colors and Backgrounds", for more details.

Example

BODY {background-attachment: scroll;}with the concept of floated elements. Ever since Netscape 1.0, it hasbeen possible to float images by declaring, for instance,<IMG SRC="b5.gif"align="right">. This causes an image to floatto the right, and allows other content (text or other images) to"flow around" the image. In the past, this was onlypossible with images and, in some browsers, tables. CSS, on the otherhand, allows any element to float, from images to paragraphs tolists. In CSS, this behavior is accomplished using the propertyfloat.

Of course, by doing this, you're setting a border on the element, and that border will show up in other user agents as well. And, just to top things off, Navigator doesn't handle padding very well, so the previous example would result in a small amount of blank space between the content box and the borders. Altogether, it isn't a very pretty picture.

to set margins for more than one side, it's almost easier tosimply use margin. From the standpoint of yourdocument's display, however, it doesn't really matterwhich approach you use, so feel free to choose whichever is easierfor you.