Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only scrolling inside one div, while website stays positioned

Tags:

html

css

xhtml

I'm trying to create a website with the following.

On top there's just a basic horizontal menu. Below that, on the left side, is another subcategory. The content will be on the right of the subcategory and can be very long.

Now what I would like is that when you scroll anywhere on the page, it only scrolls the content div while everything else stays at its original position. I have been thinking about it for some hours now but I cannot really come up with a solution on how to do this.

<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
    <div class="left_side"></div>
    <div class="right_side"></div>
</div>
</body>
</html>

.container {
width:1000px;
}

.left_side {
float:left;
width:250px;
height:500px;
background:green;   
}

.right_side {
float:right;
width:750px;
height:1500px;
background:yellow;
}

Any idea on how to do this? Thanks in advance.

like image 265
45808 Avatar asked Oct 03 '11 09:10

45808


2 Answers

Answer was given by @jao's comment. Setting all divs, except for the content one, to position: fixed.

like image 144
45808 Avatar answered Oct 18 '22 14:10

45808


Add the overflow:auto style to its class.

Full explanation: http://www.w3schools.com/cssref/pr_pos_overflow.asp

like image 36
Moo-Juice Avatar answered Oct 18 '22 15:10

Moo-Juice