Tuesday 28 February 2012

Auto Size the DIV based on its contents

To have a <DIV> shrink and enlarge based on its content, use either,

div { margin: 0 auto;  }

or

div.autosize { display: table; width: 1px; }
div.autosize > div { display: table-cell; }