Search code examples
jqueryjquery-animatebackground-size

Animate background-size width or height


How do I use JQuery's animate() on the background size of a div if I were to change either the width or the height, but not both.

For example, if I wanted to change the width, would something like the following work?

$("#buttonPic").animate({
    backgroundSizeW: "-=20px",
});

I could not find a similar question to this on SO


Solution

  • I have doubts about backgroundSizeW property, seems a bit invalid to me:

    $("#buttonPic").animate({
        backgroundSize: "-=20px auto"  // <-----it should work
    });