0

如何防止可调整大小的 div 被相邻元素重叠?我将可调整大小的 div 的 z-index 更改为 1,其余为 0。

这个例子马上就清楚了:http: //jsfiddle.net/gALUP/1/

HTML

<div id='grid'>
    <div class='outline'>
        <div class='container resizable'>
        </div>    
    </div>
    <div class='outline'>
        <div class='container'>
        </div>    
    </div>
</div>

CSS

.outline { 
    height: 200px;
    width: 200px;
    border: 1px solid black; 
    position: relative; 
    z-index: 0; 
    display: inline-block;
}
.container { 
    height: 100%; 
    width: 100%; 
    background-color: #ff0000;
}

.resizable { 
    background-color: #0000ff; 
    position: absolute; 
    z-index: 1; 
}
4

1 回答 1

0

z-index: 0从中删除.outline

.outline {
    height: 200px;
    width: 200px;
    border: 1px solid black;
    position: relative;
    display: inline-block;
}
.container {
    height: 100%;
    width: 100%;
    background-color: #ff0000;
}
.resizable {
    background-color: #0000ff;
    position: absolute;
    z-index: 1;
}

http://jsfiddle.net/elclanrs/gALUP/2/

于 2012-08-06T22:11:46.343 回答