Search code examples
htmlcssstylesheet

Make the div with expand to the width of containing spans


How can I make a div container expand its width to contain all its child spans in one row?

Please see the example fiddle here.

I would like the div to have all the buttons inside it in one row.

UPDATE The table from the example can not be removed. Moreover if I had a table instead of the div then the first table would expand. Now I have the div but that's not expanding.


Solution

  • I am going to post this as another answer, as it is not really related to my first answer.

    You can wrap your spans with another span that forces no line breaks:

    <span style="white-space:nowrap">...</span>
    

    This will make your div (and table) expand to contain the buttons.

    Example here: http://jsfiddle.net/jtbowden/JhDwt/