I am encountering an issue with centering divs within another div with overflow:auto; initially, all divs are centered using margin: 0 auto; however, when I use jQuery to resize the last div, a scrollbar appears (as expected) but the other divs remain in their original positions. I want all the divs to automatically realign themselves at the center of the scrolled div.
Here is how I resize the last div:
$('#boton').click(function(){
$('.div2').css({width:'400px'});
});
You can see it in action in this fiddle, just press the "resize" button:
http://jsfiddle.net/odabart/cAyVF/1/
EDIT:
Since I do not know which divs will be resized in advance, I am looking for a solution that uses only CSS for automation purposes; jQuery is used here solely for demonstration.