<div style="display: inline-block; margin: 0 auto;">
<input id="abc" type="button" value="button" />
</div>
I try to use the code above to set the width of equal it's content, and then center it with margin: 0 auto;
But it did not work for me on any browser. Any suggestion?
BTW, when I set the width property, it works fine.
<div style="width: 10em; margin: 0 auto;">
<input id="abc" type="button" value="button" />
</div>
display: inline-block
. When you add it back again, setting the width has no effect. See jsfiddle.net/anEvF – Moilmargin: auto
does not play nicely withfloat
. – Metamorphose