div css水平垂直居中

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style> body { padding: 0; margin: 0; } /*垂直居中*/ .box { width: 1200px; /*图片宽*/ height: 650px; /*图片高*/ position: absolute; left: 50%; top: 50%; margin-left: -600px;/* 宽/2 */ margin-top: -325px; /* 高/2 */ } </style> </head> <body> <div class="box"> <img src="img/luomu_02_02.png" /> </div> </body> </html><!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style> body { padding: 0; margin: 0; } /*垂直居中*/ .box { width: 1200px; /*图片宽*/ height: 650px; /*图片高*/ position: absolute; left: 50%; top: 50%; margin-left: -600px;/* 宽/2 */ margin-top: -325px; /* 高/2 */ } </style> </head> <body> <div class="box"> <img src="img/luomu_02_02.png" /> </div> </body> </html>

@落雨
http://ae6623.cn

效果:

img_ba7b0dead06e41967a20b35dde817789.jpg