怎么让两个DIV块,居中?

蓝with黑 2015-08-14 05:32:38


不知为什么会居左,如何让其居中
代码如下:
——————————
@media screen and (max-width: 600px) {
.heading,
.container,{
width: 400px;
}
.main{
float: left;
height: 600px;
}

.left,
.right{
float: left;
height: 200px;
width: 400px;;
background-color: blue;
}

.main {
width: 400px;
overflow: scroll;
}
.heading{
width:400px;
height:153px;
}
.container {
height: 600px;
}

header{
font-size:.6em;
font-weight: bold;
width: 100%;
}
a{
font-weight: bold;
text-decoration: none; /*decoration 修饰 装饰*/
}
header nav a{
text-decoration: none;
font-weight: bold;
}
header nav ul li a{
display: block;/*和前面的inline,是不是冲突?*/
float: left;
padding: .1em 0.8em .1em;/*top right bottom*/
border-right: .1em solid;/*每个链接的右边框*/
}
...全文
236 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xms1992 2015-08-18
  • 打赏
  • 举报
回复
感觉浮动那个有问题,正在学,暂时想不出好办法。看其他大神的。
风中剑客 2015-08-17
  • 打赏
  • 举报
回复
margin:0px auto;
我本俗人 2015-08-17
  • 打赏
  • 举报
回复
清浮动
o_n_omika 2015-08-15
  • 打赏
  • 举报
回复
去掉float:left;设置margin:0px auto;就行了
蓝with黑 2015-08-15
  • 打赏
  • 举报
回复
去掉{float:left;}就居中了, 可是为什么,宽幅为960和600px的时候设置float:left;就正常? 当浏览器宽度是小于600设置float:left;就会这样?
liwei985 2015-08-15
  • 打赏
  • 举报
回复
给你篇文章系统学习一下! http://note.youdao.com/share/?id=f93315310f22d0d2f4103bcbd6dfc922&type=note
snlixing 2015-08-15
  • 打赏
  • 举报
回复
把margin:0px auto;添加到div样式里面

61,115

社区成员

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

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