如何使另一个div内的div可见

时间:2019-05-15 03:18:54

标签: css css3

如果我给子div的页边距上限值设置为负,我想使父母div中的子div可见。

我曾尝试使用position:relative和z-index,但似乎没有用。

这是我的代码:

HTML:

<div class="main-site">
  <div class="container">
    <div class="overlap top-border-radius">
      <div id="facultylist">
        <h1>Affordable Professional Web Design</h1>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eu luctus ipsum, rhoncus semper magna. Nulla nec magna sit amet sem interdum condimentum.</p>
      </div>
    </div>
  </div>
</div>

CSS:

#facultylist {
  position: relative;
}
.main-site {
  padding: 50px 0;
}
.container {
  width: 80%;
  margin: auto;
  overflow: hidden;
}
.overlap {
  position: relative;
  background: #fff;
  margin-top: -50px;
  margin-bottom: 20px;
}
.top-border-radius {
  border-top: #006af4 3px solid;
  border-top-right-radius: 10px;
  border-top-left-radius: 10px;
}

1 个答案:

答案 0 :(得分:0)

听起来您要删除overflow: hidden上的.container

#facultylist {
  position: relative;
}

.main-site {
  padding: 50px 0;
}

.container {
  width: 80%;
  margin: auto;
  /*overflow: hidden;*/
}

.overlap {
  position: relative;
  background: #fff;
  margin-top: -50px;
  margin-bottom: 20px;
}

.top-border-radius {
  border-top: #006af4 3px solid;
  border-top-right-radius: 10px;
  border-top-left-radius: 10px;
}
<div class="main-site">
  <div class="container">
    <div class="overlap top-border-radius">
      <div id="facultylist">
        <h1>Affordable Professional Web Design</h1>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eu luctus ipsum, rhoncus semper magna. Nulla nec magna sit amet sem interdum condimentum.</p>
      </div>
    </div>
  </div>
</div>