-1
我正在嘗試製作燈泡。這裏是代碼JSfiddlez-index:20出現在z-index下方:10即使z指數更大
HTML
<input class="button" type="button">
<div id="black" style="display: none; position: fixed; width: 100%; height: 100%; left: 0; top: 0; background: rgba(51,51,51,0.7); z-index: 10;"></div>
<div id="add" style="z-index: 20; display:none; border: 2px solid;">
<input type="text" >
</div>
jQuery的
$('.button').click(function() {
$('#add').show();
$('#black').show();
})
在我的腦海時,我打
.button
,
#add
必須出現的
#black
因爲它的z-index的頂部
(20)大比#black
(10)。但它出現在#black
之下。感謝您的幫助。
z-index僅適用於定位元素。您的#add元素未定位,因此z-index被忽略,並且默認的'0'索引適用。 – 2015-02-24 21:27:16