Search code examples
htmlcsswebfootersidebar

my sidebar is going under footer


I have a practice website set up, but the sidebar keeps going under the footer or mixing with it. Here is all the code (at least for one page) and the css later. I just need a quick help, I know a fair share but not much, so please help.

<!doctype html>
<html>
<head>
<meta charset-"utf-8">
<title>Polyverse</title>
<link rel="stylesheet" href="style.css">
</head>
<!--main part-->
<!--header-->
<body>
<div id="container">
    <div>
        <body background="images/bg.jpg"></div>
    <div id="header">
        <h1><center><img src="images/header.png" width="960" height="120"         alt=">/center></h1>
<!--navbar-->
        <nav id="navbar">
            <ul>
                <li><a href="index.html">Home</a></li>
                <li><a href="about.html">About</a></li>
                <li><a href="articles.html">Articles</a></li>
                <li><a href="downloads.html">Downloads</a></li>
                <li><a href="contact.html">Contact Us</a></li>
            </ul>
        </nav>
    </div>
<!--main content-->
    <div id="sidebar">
        <p>And my sidebar stuff here.</p>
    </div>
    <div id="main">
    <h1><p>About</p></h1>
    <article><p>All my text goes here</p></article>
    </div>
<!--footer-->   
    <div id="footer">
    <address><p align=right>Last updated the 24th of July 2013<br> Polyverse     copyright</p> 
        </address>
    </div>
</div>
</body>
</html>

and the css:

 html,
#body   {
    width: 960px;
    margin: 25px auto;
    padding-left: 1em;
    font-family: Oswald, "Times New Roman",
        Times, sans-serif;
    height:100%;
    }


#container {
    position: relative;
    padding-bottom: 50px;
    min-height: 100%;
    margin: 0 auto 0 auto;
}

#navbar {
    width: 960px;
}

#navbar ul { 
    margin: 0; 
    padding: 5px; 
    list-style-type: none; 
    text-align: center; 
    background-color: #000; 
    } 

#navbar ul li {  
    display: inline; 
    } 

#navbar ul li a { 
    text-decoration: none; 
    padding: .2em 1em; 
    color: #fff; 
    background-color: #000; 
    } 

#navbar ul li a:hover { 
    color: #000; 
    background-color: #fff; 
    } 

#main {
    float: left;
    width: 600px;
}

#sidebar {
    float: right;
    width: 200px;
}
    address {
        margin-top: 1em;
        padding-top: 1em;
        border-top: thin dotted 
        }

    p {
    width: 800px;
    margin: 25px auto;
    }

#footer: {
    height: 50px;
    width: 960px;
    position: absolute;
    bottom: 0;
}

So I was just wondering, how would I fix it?


Solution

  • Well, besides the fact that your HTML is full of errors, I would recommend making container a class and add it after the top container. And yes clear your floats

    Like so ... (also cleaned up your HTML) ... http://jsfiddle.net/feitla/TC73U/

    <div class="container">
        <div id="footer" class="clearfix"> <address><p align="right">Last updated the 24th of July 2013<br/> Polyverse     copyright</p> 
        </address>
        </div>
    </div>