Search code examples
htmlcssweb-applicationstelerik

Is it possible to center the scrollbar of a div with overflow:scroll


.qsf-demo-canvas 
{ max-width: 100%;
max-height:600px;
overflow:scroll;}

Is it possible to center the horizontal scrollbar with an overflow:scroll div.

If the content was much wider than the available space the div content would be centred by default?

The user should still be able to scroll though.

thankyou


Solution

  • In JS it's possible : this scrolls the internal scroll of a div to it's horizontal middle

    var myDiv = $("#Mydiv");
    var scrollto = myDiv.offset().left + (myDiv.width() / 2);
    myDiv.animate({ scrollLeft:  scrollto});
    

    I hope that this will help you.