The center of the page is the most common form of webpage design. In the traditional table layout, we use the table's align = "center" attribute ,. The DIV itself also supports the align = "center" attribute, which can also center the DIV, but the CSS layout is to achieve separation of performance and content, while the align attribute is a style Code , Written in the DIV attribute of XHTML, there is a violation of the sharing principle (separation can make your website more conducive to management), so the CSS method should be used to center the content, take the layout code of a fixed-width column as an example to add a CSS style centered on it:
Copy code The Code is as follows: # layout {
Border: 2px solid # a9c9e2;
Background-color: # e8f5fe;
Height: 200px;
Width: 300px;
Margin: 0px auto;
}
The margin attribute is used to control the margin of the object in the top, right, bottom, and left directions. When margin uses two parameters, the first parameter indicates the top and bottom margins, and the second parameter indicates the left and right margins. In addition to using values directly, margin does not support auto. The auto value allows the browser to automatically determine the margins. Here, we set the left and right margins of the current Div to auto, the browser will set the left and right margins of the DIV to the same and display them as the center, thus achieving the effect in the game.
Note: This method is not supported by browsers earlier than IE6, And the CSS hack section below describes the solution in detail.Xmlns = "http://www.w3.org/1999/xhtml">
Center a column with fixed width (aa25.cn)