一个层垂直居中于浏览器中

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>

<title>无标题文档</title>

<styletype="text/css">

div{

position:absolute;

top:50%;

left:50%;

margin:-150px00-150px;

width:300px;

height:300px;

border:1pxsolidred;

}

</style>

</head>

<body>

<div>这里就居中了</div>

</body>

</html>

相关推荐