开发者

Shifting page content right when scroll bar becomes visible?

开发者 https://www.devze.com 2023-04-04 10:23 出处:网络
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 开发者_StackOverflow社区visible is because my c

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 开发者_StackOverflow社区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 :)!


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

body { overflow-y: scroll; }
0

精彩评论

暂无评论...
验证码 换一张
取 消