关于html中自动居中的一些小知识
2017-03-30 18:08
686 查看
自动居中代码: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>
在使用自动居中时不可设置浮动、定位,否则自动居中将不能使用。
<!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>
相关文章推荐
- 关于html的一些基础知识
- 关于HTML的一些知识(自己看)
- 关于html水平垂直居中的一些总结吧
- 关于简单的Html一些知识
- Html 中表单提交的一些知识总结——防止表单自动提交,以及submit和button提交表单的区别
- 自定义viewgroup实现自动换行的布局,同时解决自定义布局在wrapcontent下高度不能自适应的问题,plus一些关于Component重写的基础知识
- 关于HTML知识的一些总结
- 在html中,一些零散的关于标签的知识
- 关于SQL SERVER 2000的一些基本知识(2)——SQL SERVER 2000日期处理
- 关于DNS的一些基础知识
- 一些关于PHP的知识
- 关于指针的一些知识
- 一些关于sulinux的知识
- 关于dos启动的一些知识
- 关于MIME的一些知识
- 一些关于PHP的知识
- 一些关于流量和带宽的知识
- 关于垃圾回收的一些知识
- 一些有意思的HTML 知识