2012-02-26 67 views
1

在这里,我有两个设置为两个CSS背景图像的div。 我试图让div重叠,所以我可以有一个虚线的图案覆盖。 我觉得我正确的做法,但错误的div正在前进。 任何想法为什么发生这种情况?我如何覆盖div背景?

这里的网站:http://designobvio.us/portfolio/body.html

HTML:

<section class="bodySection"> 
<div id="body-wrapper" class="container_12"> 

    <div id="left-container" class="grid_5"> 
    <div class="content"> 
    </div> 
    </div><!--end of left-container-overlay--> 
</div><!--end of left-container--> 
</div><!--end of body-wrapper--> 

</section><!--end of bodySection--> 

我的CSS:

#left-container { 
    background:url(../img/sliderBG.png)transparent repeat; 
    width:400px; 
    height:100%; 
    -webkit-box-sizing:border-box; 
    -moz-box-sizing:border-box; 
    -ms-box-sizing:border-box; 
    box-sizing:border-box; 
    position:absolute; 
    overflow:hidden; 
    display:block; 
    height:100%; 
    top:0; 
    z-index:5; 
} 
#left-container .content { 
    background:url(../img/Me.jpg) repeat-y; 
    width:400px; 
    height:100%; 
    -webkit-box-sizing:border-box; 
    -moz-box-sizing:border-box; 
    -ms-box-sizing:border-box; 
    box-sizing:border-box; 
    position:absolute; 
    overflow:hidden; 
    display:block; 
    height:100%; 
    top:0; 
    z-index:1; 
} 

谢谢你们!

回答

4

我的确认为你的问题在于你在另一个嵌套的重叠元素之一,而他们通常应该只是兄弟姐妹。

看到这个捣鼓一个办法做到这一点:http://jsfiddle.net/GCprD/

+0

非常感谢。我是个白痴 – 2012-02-26 15:01:48

2

这不是不可能与你的HTML结构做到这一点,但!

http://jsfiddle.net/GCprD/1/

但我同意,M90的解决方案是更好的。