<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible"content="IE=edge,chrome=1"> <title>Examples</title> <meta name="description"content=""> <meta name="keywords"content=""> <link href=""rel="stylesheet"> <style> body { padding: 0; margin: 0; } .content { border: 1px solid red; 500px; margin: 0 auto; font-size: 12px; line-height: 1.8; } /*标准游览器版本*/ html, body { height: 100%; } .wrapper { text-align: center; 100%; height: 100%; display: table; } .subwrap { display: table-cell; vertical-align: middle; } /*IE6*/ *html .wrapper { position: absolute; top: 50%; 100%; text-align: center; display: block; height: auto } *html .subwrap { position: relative; top: -50%; text-align: center; } /*IE7 可以合并 但是为了更好说明 没有合并*/ *+html .wrapper { position: absolute; top: 50%; 100%; text-align: center; display: block; height: auto } *+html .subwrap { position: relative; top: -50%; text-align: center; } </style> </head> <body> <div class="wrapper"> <div class="subwrap"> <div class="content"> 关于 CSS 的未知高度水平垂直居中问题的未知高度水平垂直居中问题的未知高度水平垂直居中问题的未知高度水平垂直居中问题的未知高度水平垂直居中问题 <br /> </div> </div> </div> </body> </html>