html - 添加VH时图像重叠Div

标签 html css

我目前正在尝试设置 div 部分,以便它们占用大约 95vh 的网页。

问题是,当我将 vh 添加到其中一个部分时,下一部分的图像会与上一部分重叠,从而遮挡了一些内容。

所有的 div 都有相对定位,只有当我向 div 添加 vh 时才会发生这种情况。

enter image description here

section#showcase{
    height:92vh;
}
#contentShowcase{
    height:92vh;
}
section#judging {
    margin-bottom: 50px;
    height: 90vh;

}
section#judging #contentEnter {
    margin-top: 50px;
    height:350px;
}
#judgingImg {
    background: url('../images/beyond-2015-city.jpg') no-repeat 0 0;
    background-size: cover;
    height:50vh;

}
/* Section Content */
section#mainContent, 
section#mainContentEnter, 
section#mainContentAttend, 
section#gobeyond, 
section#event, 
section#eventInfo, 
section#enter, 
section#attend, 
section#judging, 
section#sponsors, 
section#venue, 
section#showcase,
section#form,
#eventQuote, 
#judgingImg, 
#sponsorsImg, 
.contentBlock {
    width: 100%;
    min-width: 100%;
    display: block;
    position: relative;
}
#scrolltoBeyond2015, #scrolltoEvent, #scrolltoShowcase, #scrolltoJudging, #scrolltoVenue {
    padding-top: 68px;
    margin-top: -68px;
    display:block;
}





 <section id="showcase" class="">
                <a id="scrolltoShowcase"></a>    
                <div class="chevronDown chevDkBlue hidden-lg hidden-md"></div>

                <div id="contentShowcase" class="row col-DarkBlue bkgrd-LtAccentBlue">
</div>
</div>
</section>
  <section id="judging">
            <a id="scrolltoJudging"></a>
            <a class="chevronDown chevtntBlue" href="#scrolltoJudging"></a>
            <div id="judgingImg"></div>
</section>

最佳答案

您可以使用 z-index 以一种分层样式设置正确的内容。

section#showcase {
   height: 92vh;
   z-index: 100;
}
#contentShowcase {
   height: 92vh;
   z-index: 80;
}

在这种情况下,section#showcase 将位于 #contentShowcase 的顶部,因为它具有较高的 z-index 值。

关于html - 添加VH时图像重叠Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32179537/

相关文章:

html - 停止使用 CSS 破坏 BR 标签

java - 为 HBox 设置背景图像 - JavaFX

javascript - 如果连接了 jquery-ui.js,我应该连接 jquery-ui.css 吗?

html - 为什么不显示:none property work on <li> elements?

html - 覆盖链接样式

css - 为什么我的 React 组件的 CSS 没有动态更新?

html - 当相邻同级元素悬停时显示元素

jquery - 如何拥有清晰、锐利和 slim 的 jqueryUI GUI 元素?

html - 如何让 a 标签垂直居中到 footer 标签?

javascript - 根据包含其他两个输入之和的一个字段添加动态输入