龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > div+css/html >

css垂直水平居中代码

时间:2012-12-29 08:41来源:未知 作者:admin 点击:
分享到:
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.111cn.net/1999/xhtml head meta http-equiv=content-type content=text/

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.111cn.net/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;

 


精彩图集

赞助商链接