You can use either of below :-
1) display : inline-block :
http://jsbin.com/feneni/edit?html,css,js,output
Uncomment the line
float:left;
clear:both
and you will find that parent container has collapsed.
2) Using display : table
http://jsbin.com/dujowep/edit?html,css,js,output