2013-12-16 52 views
1

我试图显示背景图像下面两个div s与background-color属性。 我尝试玩z-indexposition: relative但迄今没有成功。 图片在这两个div s下面不可见。下面的背景图像与背景色属性

CSS:

.bgImage { 
background-image: url('../images/footer_bg.png'); 
background-repeat: no-repeat; 
background-position: top center; 
z-index: 999; 
position: relative; 
} 

footer .bgColor1 { 
background-color: #3E3E3E; 
min-height: 223px; 
overflow: hidden; 
z-index: 0; 
position: relative; 
} 
footer .bgColor2 { 
background-color: #819808; 
min-height: 223px; 
overflow: hidden; 
z-index: 0; 
position: relative; 
} 

HTML:

<footer class="bgImage"> 
    <div class="bgColor1"></div> 
    <div class="bgColor2"></div> 
</footer> 

回答

3
  • 添加负z-index自己内心的DIV:
  • 从父DIV取出z-index

example

这会将内部DIV放置在其父项下方。如果您有兴趣了解这种工作方式read this page on MDN。基本上你必须避免在你想放置在上面的父元素(z-index和其他一些属性创建堆栈上下文)上创建本地堆栈上下文。

0

尝试使用rgba(#,#,#,0.5);指定颜色,其中#是从0到255的数字以指定颜色。结束0.5为50%不透明度。