Current problems in CSS layout
Author: Acha 2004-7-5 14:35:49
#sample {
Height: 240px; width: 400px;
Background: URL (http://www.w3cn.org/style/001/logo_w3cn_194x79.gif) #ccc no-repeat center
}
How to make DIV
The main style is defined as follows:
Body {text-align: center;} # center {margin-right: auto; margin-left: auto;
Description:
First define text-align: center in parent element; this means is in the content of the parent element; it is already possible for IE. But you can't hit in Mozilla. The solution is to set when the child element is defined, "Margin-Right: auto; margin-left: auto;"
What needs to be explained, if you want to use this method to make the entire page, it is recommended not to set it in a DIV. You can remove multiple div, as long as you define Margin-Right: Auto in each of the demolished DIVs; Margin-left: Auto;
How to make the picture in Div
Method of background. Example:
Body {background: URL (http://www.w3cn.org/style/001/logo_w3cn_194x79.gif) #fff no-repeat center;}
The key is the last center, this parameter defines the location of the image. You can also write "top left" or "bottom right", etc., you can also write a value "50 30" directly.
The effect is as follows:
How to make the text in DIV vertically
If you are text, you can't use the background method, you can use the increase in the high-distance approach to achieve vertical centers, the complete code is as follows: