jQuery(function($){
$('.to_center').each(function(){
var new_width = 0;
$(this).children('.floated').each(function(){
new_width += $(this).width();
});
$(this).width(new_width);
});
});
<div class="to_center"> <div class="floated">floated text</div> <div class="floated">floated text</div> <div class="floated">floated text</div> </div>
.to_center {
margin-left: auto;
margin-right: auto;
}
.floated {
float: left;
background-color: lightyellow;
}