【问题标题】:div relatively overlappingdiv相对重叠
【发布时间】:2019-09-07 20:59:38
【问题描述】:

我有 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;
        }

【问题讨论】:

    标签: html css positioning overlap


    【解决方案1】:

    设置margin-top:

    #sec
    {
        margin-top: -100px;
    }
    #third
    {
        margin-top: -100px;
    }
    

    http://jsfiddle.net/EPq6Z/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-09
      相关资源
      最近更新 更多