如何遍歷所有元素,並且是否存在應用於任何元素的關聯z-index樣式,將z-index樣式設置爲無...?暫時將所有css z-index設置爲「none」
然後,在完成以下函數後,將原始z索引返回原來的值。
我正在使用的小腳本。
$(document).ready(function() {
$("<div/>", {
"class": "DooSuperOverlay"
})
.prependTo("body")
.animate({opacity: 1.0}, 3000)
.fadeOut("slow");
});
恐怕如果有z索引的施加到在樣式表中的主要含有的元素,這種效果不會工作它是在current demo i have. here.
方式的CSS可以是有益的:
.DooSuperOverlay {
position:absolute;
top:0px;
left:0px;
height:100%;
width:100%;
background-color:#000;
z-index:10000;
}
#%id% {
position:relative;
z-index:10001;
}
#%id% .outer_box {
position:relative;
z-index:10001;
}
#%id% .inner_box {
position:relative;
z-index:10001;
}
如果存在任何包含使用z-index應用的#%id%div的div,即使有問題的z-index = 1 ..如果z-index:none(定義但是「none」)
這裏是上面的CSS的HTML:
<!--doobox stack begin http://www.doobox.co.uk -->
<div class="outer_box">
<div class="inner_box">
%slice% <!--replaced with content -->
</div>
</div>
<!--doobox stack end http://www.doobox.co.uk -->
如CSS,打破這個腳本:使用$
#container{z-index:1;}
<div id="container">
<!--My html resides here and if any parent has z-index like eg, no matter of value unless none.. this script breaks -->
</div>
你有沒有使用$('*')? – Val 2010-10-23 06:24:24
不,我不確定那會做什麼......? – Doobox 2010-10-23 06:26:51
說實話,可能有更簡單的方法來解決這個問題。這只是我最初的想法,是一種解決方法。我無法理解我的生活,看看爲什麼如果一個包含.outer_box div的包含div的z-index爲1或任何數字,在樣式表中應用時,它會中斷的原因......他們應該按照我的邏輯被outer_box的值較高,但不是。 – Doobox 2010-10-23 06:39:16