tags:

views:

34

answers:

5

Hi, on my website it is a div based layout when the window is reszied everything is pushed together. Such as images overlap or are moved below each other and divs also overlap each other.

How can I get it to scroll when the content of the div is greater than the window size, similar to facebook if you resize the window it prevents anything overlappting and just makes the user scroll?

body
{
    background-color: #B0B0B0;
    color: #ffffff;
    margin-top: 0px;
    margin: 0px;        
}

#header
{   
    width: 100%;
    height: 100px;
    margin: 0px;
    padding: 0px;
}

#content
{

    width: 80%;
    height: 800px;  
    margin-top: 50px;       
    margin-left: auto;
    margin-right: auto;
    padding: 30px;      
}

<div id="header">
[Header]
</div>
<div id="content">
[Content]
<img src="image1.png" /><img src="image2.png"/><img src="image3.png" />
</div>

The html is like that but obviously with more content

Hope I haven't made this too confusing, thanks.

Edit: example When you resize the browser window the images move below each other and the nav messes it. How can I enable scrolling on the whole window before this happens?

A: 

add the style

overflow: scroll;

to #content

Brad
I just added this but it shows scroll bars before it is resized, and it doesn't scroll horizontally either. Thanks.
Elliott
@Elliot, try `overflow-x: scroll; overflow-y: scroll;` And what do you mean by "resized"?
Brad
Resize the browser window. I tried that and it hasn't made any difference , I want to enable scrolling before anything starts being overlapped. On facebook you can reszie the window only to a certain point, before scrolling starts. Thanks again.
Elliott
A: 

use the overflow:scroll; to enable scrolling in the DIVs

Sachin Shanbhag
Thanks but I want the whole page to scroll not just one div.
Elliott
@Elliott - In that case try overflow:auto; or add overflow:scroll on the body class in css.
Sachin Shanbhag
+1  A: 

I believe you may want overflow: auto;

Here's a comparison between auto and scroll.

DOK
A: 

Just add overflow:auto; to your div.

You can also use the following if you only want x or y scrolling

overflow-x:auto;

or

overflow-y:auto;
Rocket Ronnie
+1  A: 

You must add white-space:nowrap; to your body tag.

Tae
That works kind of, although I have to scroll when its full size and all my content is one line.
Elliott
What happens if you forget about the white-space property and replace width:70%; by max-width:70%; in the #content element?
Tae