The horizontal center of the page is usually a headache, especially for beginners. Incompatibilities between browsers can also pose a big problem. Here's a look at the common page horizontal centering method.
See the "Mastering CSS" section below.
HTML code:
The code is as follows
<body> <div id= "wrapper" > </div> </body> ie centering method: Body { Text-align:center; min-width:760px; } #wrapper { width:720px; Text-align:left; }
IE will mistakenly think of Text-align:center as having everything centered, not just text. Then re-align the contents of the container to the left.
Non-IE:
The code is as follows:
#wrapper { width:720px; margin:0 Auto; }
How to be compatible with IE and non ie? as follows:
The code is as follows:
#wrapper { width:720px; position:relative; left:50%; margin-left:-360px; }
First, position the left edge of the container to the middle of the page, and then move it half the width to the left.
The above is the CSS Layout page Horizontal Center Common Method _ Experience Exchange content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!