关于html中自动居中的一些小知识

自动居中代码:margin:0 auto;

在使用自动居中时不可设置浮动、定位,否则自动居中将不能使用。



<!DOCTYPE HTML>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>几米简介</title>
<style type="text/css">
*{margin:0; padding:0; font-size:12px; color:#346667; font-family:Arial, Helvetica, sans-serif,"宋体";}
a{text-decoration:none;}
a:hover{text-decoration:underline;}


h2{line-height:30px; font-size:14px; margin-bottom:5px;}
p{line-height:24px; text-indent:26px; margin-bottom:5px;}


#wrap{width:770px margin:10px auto;  //自动居中,上下外边距为10px
}


#header{width:762px; border:4px solid #badbdb; background:url(../images/banner.gif) no-repeat; height:92px; text-align:right; color:#fff;}
#header a{color:#fff; margin:0 5px;}


#mainbody,#footer{
     width:100% height:200px;
}
#footer{text-align:center; padding:20px 0;}


.content{background:#eff9f9; 
padding:44px 15px 15px;
 border:4px solid #badbdb;}
.profile{background:url(../images/t_profile.gif) no-repeat #eff9f9;}
.book{background:url(../images/t_book.gif) no-repeat #eff9f9;}
.book img{
border:1px solid #b1adaa;
margin:10px 18px;}
</style>
</head>
<body>
<div id="wrap">
    <div id="header"><a href="#">联系我们</a>|<a href="#">站点地图</a></div>
    <div id="mainbody">
         <div class="content profile">
              <h2></h2>
              <p></p>
         </div>
         <div class="content book"> </div>
    </div>
    <div id="footer"></div>
</div>
</body>
</html>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值