3

I am attempting to make the margins on an image both auto. I am doing this by:

$('#headerImg').delay(100).animate({
    "margin-left": "auto",
    "margin-right": "auto"
}, 650, function() {
    //not important
});

but it does not work. It does however work if I do:

$('#headerImg').css({"margin-left":"auto","margin-right":"auto"});

My question is, why is it not working? Is there any possible way to get it to work correctly again or would I need to come up with a hacky solution to solve this problem?

Any help is greatly appreciated.

John Blact
  • 31
  • 2

1 Answers1

0

Try the following:

$('#headerImg').delay(100).animate({
    marginLeft: "auto",
    marginRight: "auto"
}, 650, function() {
    //not important
});
Maths RkBala
  • 2,207
  • 3
  • 18
  • 21