Maybe this is an easy fix, but it has been driving me crazy for a long time so I finally decided to see if a solution exists.
Simply put, I center most of my web pages within wide view-ports.
Example, a view-port might be capable of 1028px and I want my page width to only be 960px.
So my css looks like this:
#pageWrapper { /* page width is 960 pixels */
margin:0 auto;
width:960px;
}
No problem with that.
The problem comes in when I start a dynamic page that is shorter than the height of the and then my page expands (via jQuery slideOut, etc.) below the bottom of the screen and causes the vertical scrollbar to appear.
It ends up making the page flicker left during the slideOut and then flicker right during slideIn.
Is there some way through css to force a 20px right margin and still take advantage of margin:0 auto;
?
Thanks.
For vertical scrollable bar use the x and y axis. Set the overflow-x:hidden; and overflow-y:auto; that will automatically hide the horizontal scroll bar and present only vertical scrollbar. Here the scroll div will be vertically scrollable.
use it like this, $('#my_div1'). hasScrollBar(); // returns true if there's a `vertical` scrollbar, false otherwise..
To hide the vertical scrollbar and prevent vertical scrolling, use overflow-y: hidden like so: HTML. CSS.
Make sure overflow is set to "scroll" not "auto." With that said, in OS X Lion, overflow set to "scroll" behaves more like auto in that scrollbars will still only show when being used.
When the contents of the page no longer fit vertically, the browser adds a scrollbar to the right side of the window. This changes the available width in the browser window, so any content that is either centered or positioned relative to the right side of the window will move left a bit. This is very common.
There are a number of ways to control this, but the most common is to either make it so you always have a scrollbar or never have a scrollbar by controlling the overflow-y
property on the window.
Setting overflow-y: scroll
will force the scrollbars to always be there.
Setting overflow-y: hidden
will force there to never be scrollbars.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With