Do you want the div to grow relative to the browser window, or to fit the contents inside it?
If the former, you can just use the percentage width, not the pixel, and it should stay in the center.
, float... start, width:auto; ( , , ). javascript DIV, width: css , .
, : auto;. , , javascript, , margin-right margin-left.
, .
#float {
float:left;
margin-left:50%;
position:relative;
}
, jquery,
$(document).ready(function() {
var float_width = $('#float').width();
var left_spacing = float_width / 2;
$('#float').css('left', '-' + left_spacing);
});
, javascript ... , JS noob:)