css与divs的问题 [英] css problem with divs

查看:165
本文介绍了css与divs的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些div。我需要两个孩子在那里。第一个应该在静态位置和第二个位置。

I have some div. I need in two children there. The first should be at static position and under second.

alt text http://a.imageshack.us/img685/8185/imgpk.png

橙色矩形应定位到父div并具有静态位置(例如,top:20px;)。第二个孩子(红色矩形)应该在所有另一个div。

Orange rectangle should be positioned to the parent div and has static position (for example, top: 20px;). The second child (red rectangle) should be over all another divs.

我试图使橙色div绝对和使用z-index操纵绘制队列。

I tried to make orange div absolute and use z-index to manipulate draw-queue. But it's always at the top (or below all another, when z-index is negative)

你能帮我一下吗?

UPD

<div id="content">
      <div id="secondChild"></div>
</div>
<div id="firstChild"></div>

#content
{
    position: absolute;
    width: 100%;
}
#secondChild
{
    z-index: 9999;
}
#firstChild
{
    position: absolute;
    z-index: -1;
}


推荐答案

Z-索引上下文,所以在你的情况下,它需要应用于#content,而不是第二个孩子。此外,如果红色div在页面流中的橙色div之后,它应该已经与您需要的方式重叠了。

Z-index works withing rendering context, so in your case it needs to be applied to #content, not second child. Also, it should already overlap the way you need if the red div is after the orange div in the page flow.

太糟糕了,你不给完整的)源,边距等,以便我可以尝试重现这一点。

Too bad you don't give the full(er) source, with margins etc, so that I can try to reproduce this.

这篇关于css与divs的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆