<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>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…