我如何使身体居中?我正在尝试构建一个960px的网络,但是在测试时它始终坚持左侧(附上截图)。
我该如何解决这个问题?感谢所有可以提供帮助的人!
<html>
<head>
<style>
body {
background-color:WHITE;
width: 960px centered;
}
.one {
background: #B1B4B5;
color: BLACK;
font-size: 60px;
width: 60px;
height: 60px;
overflow:hidden;
float:left;
position:absolute;
top: 0px;
left: 0px;
text-align: center;
}
.two {
background: #B1B4B5;
color: BLACK;
font-size: 60px;
width: 60px;
height: 60px;
overflow:hidden;
float:left;
position:absolute;
top: 0px;
left: 900px;
text-align: center;
}
.three{
background: #B1B4B5;
color: BLACK;
font-size: 60px;
width: 60px;
height: 60px;
overflow:hidden;
float:left;
position:absolute;
top: 500px;
left: 0px;
text-align: center;
}
.four {
background: #B1B4B5;
color: BLACK;
font-size: 60px;
width: 60px;
height: 60px;
overflow:hidden;
float:left;
position:absolute;
top: 500px;
left: 900px;
text-align: center;
}
</style>
</head>
<body>
<a class="one">1</a>
<a class="two">2</a>
<a class="three">3</a>
<a class="four">4</a>
</body>
</html>
答案 0 :(得分:0)
检查
body
{
background-color: WHITE;
//incorrect value (width: 960px centered;)
width: 960px;
margin: 0 auto;
position: relative;
}
答案 1 :(得分:0)
在CSS中,将body
规则更改为:
body {
background-color: white;
width: 960px;
margin: auto;
position: relative;
}
centered
中没有width
值。