Animation adds CSS overflow:hidden during its creation. When it stops, overflow returns to its previous state, so you should just add CSS overflow:hidden to #Layer1
In addition, I suggest you use the jQuery doc ready functionality instead of the built-in onload Javascript.
So your whole JS will be:
$(function() { // <== doc ready $("#Layer1").css("overflow","hidden").animate({width:"20px"},1000); });
I'm not quite sure what you are trying to execute with your code, but you can also include overflow:hidden in CSS for #Layer1 :
#Layer1 { position:absolute; width:200px; height:115px; z-index:1; left: 445px; top: 64px; overflow:hidden; }
Using the above CSS, you can use your source code, just wrap it in a finished document and remove the onload from the HTML:
$(function() {
Note that the width of the div is less than the width of the image. Not sure if this is on purpose.
source share