我正在一個項目中,當用戶將鼠標懸停在一個框上時顯示消息,我創建了一個場景來模擬我遇到的問題。z-index和溢出沒有正確顯示div
藍色框應該顯示爲完整的250像素定義,不會被剪裁到200像素,包含div設置爲,有無論如何繞過這一點,我可以坐在包含div的藍色框作爲其需要自包含的UserControl的所有部分。
#first {
width: 200px;
height: 200px;
background-color: green;
overflow: hidden;
}
#second {
width: 50px;
height: 50px;
background-color: red;
position: relative;
}
#fourth
{
width: 250px;
height: 50px;
background-color: blue;
position: absolute;
z-index: 100;
}
<div id="first">
<div id="second">
<div id="fourth">
test
</div>
</div>
</div>
刪除'#first {溢出:隱藏}'因爲這是預期的行爲,也沒有工作除了圍繞更改CSS/HTML結構 – Justinas