Jquery Computed CSS不适用?

时间:2014-12-08 21:37:30

标签: javascript jquery html css

HTML:

<div class="warframe_option">
<div class="w1 woption"></div>
<div class="w2 woption"></div>
<div class="w3 woption"></div>
<div class="w4 woption"></div>
<div class="w5 woption"></div>
<div class="w6 woption"></div>
<div class="w7 woption"></div>
<div class="w8 woption"></div>
<div class="w9 woption"></div>
<div class="w10 woption"></div>
<div class="w11 woption"></div>
<div class="w12 woption"></div>
<div class="w13 woption"></div>
<div class="w14 woption"></div>
<div class="w15 woption"></div>
<div class="w16 woption"></div>
<div class="w17 woption"></div>
<div class="w18 woption"></div>
<div class="w19 woption"></div>
<div class="w20 woption"></div>
<div class="w21 woption"></div>
<div class="w22 woption"></div>
</div>

Javascript:

$top = 0;
$left = 0;
for(var i = 1; i < 23; i++) {
    $('.w' + i).css("background", "url(" + window.myNamespace['w' + i].image +") no-repeat");

    if(i >= 2) {
        $('.w' + i).css("position", "relative");
        $('.w' + i).css("top", $top + "%");
        $('.w' + i).css("left", $left + "%");
    }

    $top = $top - 44;
    $left = $left + 12;
}

的CSS:

.woption {
    background-size:100%;
    width:10%;
    border-radius:15px;
    cursor:pointer;
}

问题在于它正确地计算了所有内容,但它并没有显示出来。我在google chrome的控制台中没有出错,所以我不知道为什么这样做不起作用。

0 个答案:

没有答案