2012-10-19 116 views
0

我正在绑定div div来显示顶部和底部的淡入淡出使用和图像。css堆叠div

外部div(“旋转器”)有一个背景图像,在顶部和底部有一个渐变,中间是透明的。在中间,我想要显示内容或图像,并将顶部的div背景图像放在顶部,以便始终可以看到顶部和底部的渐变以及背后的内容/图像。

感谢您的任何帮助。现在背景图片总是被内部div内容/图片覆盖。

这里是我的代码:

<div id="rotator"> 
<div class="content">this is my content</div> 
</div> 

#rotator 
{ 
    width:990px; 
    height:300px; 
    background: url('../Images/TIBC_Base/featured_area.png') repeat-x; 
z-index:99; 

} 
#rotator .content 
{ 
    width:990px; 
    height:300px; 
z-index:-1; 
} 
+0

你可以让jsfiddle? – Selvamani

+0

http://jsfiddle.net/TgQ5s/ –

+0

随着背景图片:http://jsfiddle.net/TgQ5s/1/ – user891073

回答

0

我在里面新增了.image-frame div以下风格为.content带来影子。并检查更新的code

#rotator 
{ 
    width:990px; 
    height:300px; 
    position:relative; 
} 
.image-frame{ 
    position:absolute; 
    left:0; 
    top:0; 
    width:100%; 
    height:100%; 
    background: url('http://i47.tinypic.com/2lctevc.png') repeat-x; 
} 
0

当你使用Z-index属性所需的位置属性必须,尽量使用类似

postition:相对

<div id="rotator"> 
<div class="content">this is my content</div> 
</div> 

    #rotator 
    { 
     width:990px; 
     height:300px; 
     background: url('../Images/TIBC_Base/featured_area.png') repeat-x; 
    position:relative; 
    z-index:99; 


    } 

    #rotator .content 
    { 
     width:990px; 
     height:300px; 
    position:relative; 
    z-index:-1; 
    } 
+0

这是一个jsfiddle与附加的背景图片。 http://jsfiddle.net/TgQ5s/1/ – user891073

+0

感谢senthilbp,但这似乎并没有伎俩。内容仍然超出背景。 – user891073