The following will give you your desired effect and scroll to the center of the div through a simple change in your jQuery:
$(document).ready(function(){
var outerContent = $('.abc');
var innerContent = $('.abc > div');
outerContent.scrollLeft((innerContent.width() - outerContent.width()) / 2);
});
This code will set the scroll bar to the center of the inner content.
But lets examine why. We know the minimum value for scrollLeft is
zero, and the maximum is inner.width() - outer.width(). So, half way
is easily half the maximum.
There is plenty more information on the subject here.
Demo
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…