Independent column scroll in HTML page
Set a height for the columns, and set overflow: auto
. You could also put all rules inside the same CSS selector. Like this:
#left, #right {
float: left;
width: 50%;
height: 200px; /* Set your height here */
overflow: auto;
}
The earlier postings improved a little:
- 100% html and body size .... without scroll bar
- margins for the left and right boxes
- individual scrollbars only when needed ("auto")
- some other details: Try it!
Fiddle: 2 independently scrolling divs
html, body {
height: 100%;
overflow: hidden;
margin: 0;
}
#content {
height: 100%;
}
#left {
float: left;
width: 30%;
background: red;
height: 100%;
overflow: auto;
box-sizing: border-box;
padding: 0.5em;
}
#right {
float: left;
width: 70%;
background: blue;
height: 100%;
overflow: auto;
box-sizing: border-box;
padding: 0.5em;
}
See this fiddle
#content, html, body {
height: 98%;
}
#left {
float: left;
width: 50%;
background: red;
height: 100%;
overflow: scroll;
}
#right {
float: left;
width: 50%;
background: blue;
height: 100%;
overflow: scroll;
}
body {
margin: 0;
}
#left {
position: fixed;
background-color: green;
width: 50%;
height: 100%;
overflow: auto;
}
#right {
position: fixed;
background-color: red;
width: 50%;
height: 100%;
right: 0;
overflow: auto;
}
Please see this fiddle