碰着过有的浏览器中网页主体内容是居中的(网页居中),可有的阅读器中HTML网页整体是靠右(居右)的。标题起因在于没有配置css机关居中属性margin。
html最外层DIV配置宽度同时需求设置居中CSS属性。
margin:0 auto
HTML布局居中源代码:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>html网页居中 www.CSS5.com</title> <style> #warp{margin:0 auto;width:980px} #header{ bac千克round:#CCC; height:120px} #cent{ background:#F5F5F5; height:500px} #footer{ background:#333; height:180px; color:#FFF} </style> </head> <body> <div id="warp"> <div id="header">网页头部</div> <div id="cent">网页两头模式</div> <div id="footer">网页底部</div> </div> </body> </html>
涉猎器中运转代码,也许看见网页居中的,同时主体网页模式宽度为980px。当然头部、模式、底部周边不有设置装备摆设宽度,不有配置居中,但因为外层另有一个<div id=warp></div>设置装备摆设宽度和居中,以是网页HTML个人完成居中。
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h53270.shtml