【发布时间】:2014-10-23 01:09:23
【问题描述】:
我正在设计一个 div 相互重叠的设计,我会为每个类的成员单独增加 z-index 1。而且我觉得jquery 有更好的方法。
我想要的是类似于 section 类的每个 div 的 z-index 比前一个大但不会被不属于特定类成员的 div 丢弃,例如
<div class="section" style="z-index:1">Lorem</div>
<div class="section" style="z-index:2">Lorem</div>
<div id="OutOfPlaceDiv">Foo</div>
<div class="section" style="z-index:3">Lorem</div>
【问题讨论】:
-
$('.section').each(function(index, el) { $(el).css('z-index', index + starting_z-index_value); });将starting_z-index_value替换为您想要开始的值。