我想要两个div。看起来是这样的:
问题是,如果我刚刚设置margin-top: -50pxDIV2就变成了TOP。
如果我使用z-index,DIV2会落后,但是DIV2上的表单不能使用,因为它有点落后,不能单击、选择或任何这些。
我该怎么做?
第1部分css:

position:relative;
height: 350px;
margin-top: -50px;
z-index: -10;

第2部分css:
padding: 24px;
z-index: 10;
margin-bottom: -50px;

最佳答案

在不知道任何细节的情况下,它可能与负z索引有关。
叠加顺序区分正值和负值:
规范定义了7个绘画层。从后到前,他们
是:

The borders and background of the current stacking context
Positioned descendants with negative z-index
Nonpositioned block-level descendants with no z-index property defined -- paragraphs, tables, lists, and so on
Floating descendants and their contents
Nonpositioned inline content
Positioned descendants with no z-index, z-index: auto, or z-index: 0
Positioned descendants with z-index greater than 0

来源是here
尝试使div1上的z-index为正,而不是div2上的z-index为负
注意,z-index仅适用于位置值为绝对、固定或相对值的框的堆栈级别。

关于css - CSS:DIV重叠问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8896507/

10-12 12:36
查看更多