Scroll Bar Appears and Makes Page Jump

2019-06-08 06:30发布

问题:

I have aJQuery animation that expands a DIV and makes it go larger than the browser. When that happens a scroll bar appears and meks the page look as if it jumps. Anyone have any solutions for this?

http://www.kerrydean.ca/MATHESON/home5.html

回答1:

html {
  overflow: -moz-scrollbars-vertical; 
  overflow-y: scroll;
}

See: Making the main scrollbar always visible.



回答2:

If you know you will need need the overflow then turn it on in CSS

body {
  overflow: scroll;
}


回答3:

I guessing that the page looks like it 'jumps' because the vertical scroll bar is dynamically added to the window when the content goes below the bottom of the browser.

You can make the vertical scroll bar always appear regardless whether or not there is content by setting the height of your HTML tag to 101%:

<html xmlns="http://www.w3.org/1999/xhtml" style="height: 101%;">


回答4:

If the page is never supposed to scroll, you can set overflow: hidden on the body tag. Also, you might set make the gutters on the left side constant width.



回答5:

You can do "overflow-y:hidden" on the body element and it will disable scrollbar