css垂直水平置中代碼

來源:互聯網
上載者:User

<!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;

 

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.