tags:

views:

47

answers:

3

Hello,here is my code :

function toggle() 
{
$("#Layer4").animate( { width:"20%"}, 1000 );
$("#Layer6").animate( { width:"20%"}, 1000 );
}

Now what happens is,that Layer4 and Layer6 witness some animation,but the interestingly the height changes and not the width.Also,after a second,the original dimensions are restored

Why is this happening ?

Thanks

A: 

Can you upload all of the code please?

ABailiss
well, this can be a comment.
Ninja Dude
<body onload="open()"><div id="Layer4"><img src="friend-line.jpg" width="243" height="380" /></div><div id="Layer5" onClick="toggle()"><img src="toggle_in.jpg" width="7" height="50" /></div><div id="Layer6"></div></body>
Anant
@Anant - He doesn't have sufficient rep to leave comments yet.
Ender
A: 

I don't believe you'll have consistent results using %. Try using pixels instead. If you must use % make sure that you don't have a surrounding div which the width is also set in %. My guess is that that is the case.

Martin Murphy
yep,tried using px. The dimensions still get reset within seconds :/
Anant
any idea as to why this is happening ?
Anant
A: 

You can't reduce the size of the div by less than the img tag. If you want that behavior you'll need to replace the img tag with a background-image style.

Martin Murphy