Search code examples
htmlcssscrollpositionfixed

Why does my content get cut off without the option to scroll?


I'm writing a small website to learn HTML and CSS and I'm having trouble getting my content to scroll in any direction.

When the browser window is resized to the point where any of the content cannot fit, instead of allowing a scroll, it just disappears. The Login button's div is supposed to appear 950px from the left. Meaning that if the browser window is smaller then that, it will allow you to scroll over, right?

And the News box will display any content written until it reaches the bottom of the browser window. Then it won't scroll or display.

Any suggestions?

The HTML is here is here and the CSS is here.


Solution

  • Your CSS has many position:fixed attributes in it. When an object's position is set to fixed, it will stay stationary, even if you are scrolling. Therefore, there was nothing that can move, so you couldn't scroll. Try changing your CSS to the following:

    body {
    background-color: #222222;
    overflow: auto;
    color: #ffffff;
    font-family: verdana, sans-serif;
    }
    a { color: #ffffff; }
    a:visited { color: #ffffff; }
    
    #page_header {
    margin-top: 55px;
    margin-left: 100px;
    font-size: 50px;
    }
    
    #user_info {
    /*right: 50px;*/
    left: 950px;
    top: 60px;
    position:absolute;
    }
    #user_info a {
    padding: 15px;
    text-decoration: none;
    font-size: 35px;
    }
    #user_info a:hover {
    background-color: #606060;
    }
    
    #boxes {
    margin-top: 100px;
    margin-left: 100px;
    }
    
    #left_content_box {
    padding: 20px;
    background-color: #00cdcd;
    width: 600px;
    float: left;
    }
    #left_content_box header {
    top: 15px;
    left: 50px;
    font-size: 25px;
    }
    #left_content_box section {
    padding: 10px;
    }
    #left_content_box section header {
    padding-top: 25px;
    position: relative;
    font-size: 20px;
    left: 0px;
    }
    #left_content_box section p {
    position: relative;
    top: 20px;
    left: 10px;
    font-size: 15px;
    overflow: auto;
    }
    

    This will keep everything in the same position as it was, except the page can now scroll when the browser is resized to a point that it cannot display all its contents.