HTML左中右 布局为什么不能居中

java120936434 2011-11-17 02:20:48
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>左中右</title>
</head>
<style type="text/css">
.mian{
margin:10px auto;
}
#top{
height:600px;
width:200px;
background-color:#00FF00;
float:left;
}
#zhong{
height:600px;
width:500px;
margin:0px 10px;
background-color:#003399;
float:left;
}
#bottom{
height:600px;
width:200px;
background-color:#00FF00;
float:left;
}
</style>

<body>
<div class="mian">
<div id="top"></div>
<div id="zhong"></div>
<div id="bottom"></div>
</div>
</body>
</html>
...全文
243 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
a897265809 2011-11-21
  • 打赏
  • 举报
回复
与上楼同解。
whsubway 2011-11-18
  • 打赏
  • 举报
回复
body{
margin:0px;
padding:0px;
text-align:center;
}
.mian{
margin:10px auto;
width:920px;
}

这样就可以了哦~固定宽度且居中~


920=200+10+500+10+200
torrychang 2011-11-18
  • 打赏
  • 举报
回复
一直用的960px[Quote=引用 7 楼 qinglinglaoren 的回复:]

引用 4 楼 mubeibei 的回复:
引用 1 楼 java120936434 的回复:
.mian{
width:920px;
margin:10px auto;
}


楼主别920px了 现在基本上都是1002px~`国际惯例,你懂得~·

不是960px吗?
[/Quote]
qinglinglaoren 2011-11-17
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 mubeibei 的回复:]
引用 1 楼 java120936434 的回复:
.mian{
width:920px;
margin:10px auto;
}


楼主别920px了 现在基本上都是1002px~`国际惯例,你懂得~·
[/Quote]
不是960px吗?
gao520qiang 2011-11-17
  • 打赏
  • 举报
回复
div不给width默认宽度是百分之百与body相同!
qinhu2926 2011-11-17
  • 打赏
  • 举报
回复
.mian没有给他宽度,所以他不能居中,他就会根据窗口的宽度来进去定位了,
MuBeiBei 2011-11-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 java120936434 的回复:]
.mian{
width:920px;
margin:10px auto;
}
[/Quote]

楼主别920px了 现在基本上都是1002px~`国际惯例,你懂得~·
persuit666 2011-11-17
  • 打赏
  • 举报
回复
mian 样式里需要加个固定宽度 就ok,比如width:910px;
三石-gary 2011-11-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 java120936434 的回复:]

.mian{
width:920px;
margin:10px auto;
}
[/Quote]
你自己已经实现了啊。。接个分
java120936434 2011-11-17
  • 打赏
  • 举报
回复
.mian{
width:920px;
margin:10px auto;
}

61,112

社区成员

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

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