How to center the DIV
The main style definitions are as follows:
body {text-align:center;}
#center {Margin-right:auto; Margin-left:auto; }
Description
The text-align:center is defined first in the parent element, which means that the content within the parent element is centered, and the setting for IE is already available. But it can't be centered in Mozilla. The solution is to add "Margin-right:auto" when the child element is defined; Margin-left:auto; ”
It should be explained that if you want to use this method to make the whole page to center, it is recommended not to set in a Div, you can split the div in turn, as long as in each of the split Div defined margin-right:auto; Margin-left:auto; You can do it.
How do I make a picture center vertically in a div
Use the background method. Example:
Body{background:url (http://www.w3cn.org/style/001/logo_w3cn_194x79.gif) #FFF No-repeat Center;}
The key is the final center, which defines the position of the picture. It can also be written as "top left" or "bottom right", or write the value "50 30".
The effect is as follows:
How do I make text vertically centered in a div
If it is text, you can not use the background method, the way to increase the line spacing to achieve vertical center, the complete code is as follows:
Test content
Description
Vertical-align:middle the vertical center of the row, we increase the line spacing to as high as the entire Div, and then insert the text in the vertical center of the line-height:200px.