Plot Explanation: There's a bird that should collect it's legs before flying. Bird's body, legs and eye are background-image
s of separate div
s. I used jQuery's animate method to change legs position and put them inside the bird's body.
Problem: Instead of legs going under the bird's body, they stay above it.
Question: What am I doing wrong that makes bird's legs not going under it?
Images:
HTML:
<div id="gonji">
<div class="legs"></div>
<div class="body">
<div class="eye"></div>
</div>
</div>
CSS:
#gonji { width: 80px; height: 55px; position: relative; }
#gonji .body { width: 80px; height: 55px; background: url('../gonji/gonji.png') no-repeat scroll center center transparent; z-index: 998; }
#gonji .eye { width: 5px; height: 4px; background: url('../gonji/gonji_eye.png') no-repeat scroll center center transparent; position: absolute; top: 13px; left: 30px; z-index: 999; }
#gonji .legs{ width: 9px; height: 17px; background: url('../gonji/gonji_legs.png') no-repeat scroll center center transparent; position: absolute; top: 35px; left: 30px; z-index: 1 }
JS:
var $gonjiLegs = $("#gonji").find(".legs");
var gonjiOrigLegsPos = $gonjiLegs.position();
$gonjiLegs.animate({ 'top': gonjiOrigLegsPos.top - 17 }, 'fast');
You're missing a position
property on #gonji .body
.. z-index only works on positioned elements
Try adding position: relative;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With