css教程垂直水平居中代码
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.jzread.com/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>css垂直水平居中代码</title>
<style type="text/css">
.cncenter{
height:30px;
width:600px;
margin:0px auto;
background:#0c6;
}
</style>
</head>
<body>
<div class="cncenter">
</div>
</body>
</html>
div居中的完美解决方案! (水平垂直居中)
1,关于居中使用css为:position:fixed;left:50%;top:50%;margin-left:width/2;margin-top:height/2;
对于ie6,只能把position:改成absolute;
时间: 2024-10-04 13:13:21