我有3个div。我需要得到这些重叠,但我 不能使用绝对定位 。我怎样才能做到这一点? 我的目标是使用响应式布局(无修复px值)
<div id="hold" style="background-color: #CCCCCC;padding: 10px">
<div id="first" style="width: 100px;height: 100px;background-color: red;z-index: 1"></div>
<div id="sec" style="width: 100px;height: 100px;background-color: greenyellow;z-index: 3"></div>
<div id="third" style="width: 100px;height: 100px;background-color: #a3dbec;z-index: 5"></div>
</div>
我使用了以下css。
#first,#sec,#third{
margin: 0 auto;
position: relative;
top: 0;
}
答案 0 :(得分:3)
设置margin-top
:
#sec
{
margin-top: -100px;
}
#third
{
margin-top: -100px;
}