I have an website and some problems with the scrollbar.
What I want I can best explain with this image.
But I can't get the scrollbar like this.
I have tried some, here is the jsfiddle
In this fiddle I also have:
div[role="main"]
{
overflow-y: scroll;
margin: 60px 0;
}
But this margin is not OK, how do I know what margin I need without knowing the header and footer height.
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.
If your header row locates on the top of the worksheet, please click View > Freeze Panes > Freeze Top Rows directly. See screenshot. Now the header row is frozen. And it will follow the worksheet up and down while scrolling the worksheet.
Set the overflow-y: hidden; and overflow-x: auto; that will automatically hide the vertical scroll bar and present only the horizontal scrollbar. The white-space: nowrap; property is used to wrap text in a single line. Here the scroll div will be horizontally scrollable.
Answer: Use CSS fixed positioning You can easily create sticky or fixed header and footer using the CSS fixed positioning. Simply apply the CSS position property with the value fixed in combination with the top and bottom property to place the element on the top or bottom of the viewport accordingly.
This can be slowed by using padding and box-sizing = border-box on body ( with body height 100% it will count padding into height, so the box with scroll will be exactly between header and footer)
html {
overflow: hidden;
height: 100%;
}
body {
padding: 60px 0px;
height: 100%;
box-sizing: border-box;
}
div[role="main"] {
overflow-y: scroll;
height: 100%;
}
see http://jsfiddle.net/wPucQ/
EDIT: Added forgotten HTML tag in code
You need to give the scrollable element a height so the scroll-bar position can be calculated.
div[role="main"]
{
height:400px;
overflow-y: scroll;
margin: 60px 0;
}
http://jsfiddle.net/gkxV4/
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