html 中两个层重叠并居中对齐

居中对齐指的是不管多大的屏幕,两个层总是在屏幕中央。

第1个回答  2010-12-04
一般都是用相对定位,不推荐绝对定位;
<head>
<style>
.div1
{
width:400px;
height:400px;
background-color:#FF0000;
}
.div2
{
width:200px;
height:200px;
margin-top:100px;
margin-left:100px;
background-color:#00FF00;
}
</style>
</head>
<body>
<div class="div1">
<div class="div2"></div>
<div>
</body>本回答被提问者和网友采纳
第2个回答  2010-12-03
别学那个啦 换换口味吧