您的位置:首页技术文章
文章详情页

设置了margin:0 auto;无法居中咋回事?

【字号: 日期:2022-10-28 10:32:31浏览:71作者:猪猪

问题描述

<!DOCTYPE html>

<html>

<head>

<meta charset ="UTF-8">

<title>1.单列等宽布局</title>

<!--样式-->

<style type="text/css">

.container{

max-width: 960px;<!--设置最大宽度为960px-->

margin:0 auto;<!--设置内部的块元素水平居中-->

}

.header{

height:50px;

background-color:#21ff80;

}

.main{

height:600px;

background-color:#80007f;

}

.footer{

height:100px;

background-color:#21ff80;

}

</style>

</head>

<body>

<h4>单列等宽布局基本思路:</h4>

<p>1.页面的头部,主体和底部全部放在一个容器中统一设置<br>

2.容器中的子块只需要设置一下高度即可

</p>

<div>

<div>头部</div>

<div>主体</div>

<div>底部</div>

</div>

</body>

</html>

问题解答

回答1:

好了解决了,注释出了问题,用的Notepad++写的,直接用快捷键注释,没注意看。

回答2:

你只写了样式,但是并没有使用样式

相关文章: