1

I'm making a dynamic page, in HTML/CSS using Javascript and jQuery. The height of this page can change, and a scrollbar can appear or disappear. Also, I want the content to be centered. To achieve that, I use margin: 0 auto;. But when the scrollbar shows itself (or hides itself), the page moves a little on the side.

How can I prevent it from moving left and right ?

EDIT

Here's a jsfiddle to see what the problem is (sorry, the content is in French): http://jsfiddle.net/r4jspomr/

You can click on the titles to extend/retract the content under it

Bosion
  • 155
  • 1
  • 1
  • 7
  • Please provide the code and JSFiddle example – Aziz Sep 18 '15 at 15:12
  • Does this answer your question? [Prevent scroll-bar from adding-up to the Width of page on Chrome](https://stackoverflow.com/questions/18548465/prevent-scroll-bar-from-adding-up-to-the-width-of-page-on-chrome) – handle Dec 11 '19 at 12:05

1 Answers1

0

it is default Behavior of browsers, you can disable scrollbar using the following code and then use a beautiful custom-scrollbar like this

$("body").css("overflow", "hidden");
Hamed
  • 61
  • 7
  • I had already guessed that it was their default behavior. I was wondering if there was a workaround that did not imply using a custom scrollbar – Bosion Sep 18 '15 at 15:49
  • @Bosion: maybe you find a solution, but there are many browsers with different behaviors – Hamed Sep 18 '15 at 15:55