【发布时间】:2017-01-19 08:23:52
【问题描述】:
我很难理解为什么我的相对 div (.wrap) 不会显示其 css 定义的背景颜色或图像。 body 有自己的背景, .wrap 为 div 及其内容创建一个新背景。 (.local 是我试图让 .wrap 为其创建背景的绝对 div,因为它是我需要从 .wrap 获得单个共享背景的众多 div 之一)
任何帮助将不胜感激!
CSS
body{
min-height: 100%;
min-width:100%;
font-family: 'Open Sans', sans-serif;
background-color: gray;
}
.wrap {
position: relative;
height: 100%;
width: 70%;
background-color: white;
left: 15%;
}
.local {
position: absolute;
height: 40%;
width: 20%;
}
HTML
<!-- MAIN BODY -->
<div class="wrap">
<!-- LOCAL WEATHER -->
<div class="local">
<p>THIS IS A TEST PARAGRAPH TO SHOW THE RELATIVE DIV ISSUE</p>
<!-- <img src="images/weatherphoto.png"> -->
</div>
</div>
【问题讨论】:
-
您需要将 z-index 属性添加到 .wrap 类中,如下所示: .wrap{z-index:99999999} 或本地类。玩这个属性。我相信这就是你的解决方案。
-
刚刚试了,没用prntscr.com/dxfosy这里有一个链接,即使在添加 z-index 之后,我也能看到它的样子……包含“这是一个测试段落”在 .local div 内,它后面不显示在 .wrap div 中定义的白色背景