Revised (works if you have multiple children):
You can use jQuery (Look at the JSFiddle link)
var d= $('div');
var w;
d.children().each(function(){
w = w + $(this).outerWidth();
d.css('width', w + 'px')
});
Do not forget to include the jQuery...
See the JSfiddle here