一个div容器内包含横排的多个div,如何让他们整体居中?除了padding和margin

aeoluszzf 2007-05-16 10:28:21
代码如下
------------------------------------------
<style type="text/css">
.main{width: 400px; height: 200px; background: #999;}
.dv{width: 100px; height: 100px; background: #999; float: left;}
</style>
<div class="main">
<div class="dv">dv1</div>
<div class="dv">dv2</div>
<div class="dv">dv3</div>
</div>
...全文
771 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
muxrwc 2007-05-16
  • 打赏
  • 举报
回复
<style type="text/css">
.main{width: 400px; height: 200px; background: #999; text-align:center;}
.dv{width: 100px; height: 100px; background: #999; float: left; text-align:left;}
.center {
width:300px;
margin:auto;
}
</style>
<div class="main">
<div class="center">
<div class="dv">dv1</div>
<div class="dv">dv2</div>
<div class="dv">dv3</div>
</div>
</div>

61,124

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧