views:

71

answers:

1

Hi everyone, so I have this image that I want to magnify on mouseover, so I have something like this.

$('#something').animate({
            width: bigger-than-now,
            height: bigger-than-now
          });

but I found that this always expand toward bottom-right, when I want it to expand toward bottom-left? does anyone know how I can accomplish this? thanks in advance!

i.e. Well, I do find that it would do bottom-left if i set the css position to absolute, and top, right=0. but then I would like relative positioning in my case.

A: 

If you don't want to use position absolute, you could give the image a large initial padding and then reduce that padding in the direction you want the image to expand.

CSS

#something {
    height: 100px;
    width: 100px;
    padding-top: 10px;
    padding-left: 10px;
}

jQuery growth of 10px to the top and left

$('#something').animate({
    width: 110,
    height: 110,
    paddingTop: 0,
    paddingLeft 0
});
Pat
Thanks. It works. The sad thing is, I have a background-color, so it looks odd if i do the padding, i would suggest margin, but then i don't think the animate would work the same way...any good suggestion?
Have your tried margin? It should work the same with animate.
Pat