0

Is it possible using jQuery to shift the content of a page say 10px to the right when the scroll-bar becomes visible. The reason it isn't automatically visible is because my content expands via jQuery, and when it reaches the point at which it's height exceeds the browsers, the scroll-bar is displayed, causing all page content to shift to the right about 10px or so.

I'd like it so that this doesn't happen, and the content stays in the same position, while the scroll-bar is visible.

I'm not sure if CSS properties such as body { scroll-bar: x; } (I'm assuming that scroll-bar is the correct property for the scroll-bar) can be used as jQuery selectors, and even if so, how this would work?

Any help, answers, references to other articles where this is done would be great :)!

Avicinnian
  • 1,822
  • 5
  • 37
  • 55
  • Possible duplicate of [How Do I Stop My Web Content From Shifting Left When The Vertical Scrollbar Appears? Roll-Up of Advice 2017](https://stackoverflow.com/questions/45524214/how-do-i-stop-my-web-content-from-shifting-left-when-the-vertical-scrollbar-appe) – JBH Aug 05 '17 at 17:18

1 Answers1

0

You could use CSS to force the scrollbar to always be visible:

body { overflow-y: scroll; }
Nikola K.
  • 7,093
  • 13
  • 31
  • 39
mVChr
  • 49,587
  • 11
  • 107
  • 104
  • Yeah, I thought about that, but I'd rather it wasn't. Really it might be a little too much overhead to do what I want, but damn I hate browser default scroll-bars. – Avicinnian Sep 10 '11 at 04:53
  • I'd say you need to get over one or the other and save your hatred for things that matter. – mVChr Sep 10 '11 at 19:41