2013-07-25 62 views
0

我有一个练习网站设置,但边栏继续在页脚下或与它混合。这里是所有代码(至少对于一个页面)和稍后的css。我只需要一个快速的帮助,我知道一个公平的份额,但不多,所以请帮助。我的侧边栏是在页脚

<!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> 

和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; 
} 

所以我只是在想,我怎么会解决这个问题?

+0

您的CSS和HTML都加载了语法错误。在尝试排除其他任何问题之前先解决这些问题。 –

回答

0

那么,除了一个事实,即你的HTML是充满了错误,我会建议做container类和顶部容器后添加。是的clearfloats

像这样...(也清理你的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> 
+0

好吧,一切正常。我在.container类中输入了宽度,但每当我为标题添加标记时,

中的其余文本都会穿过我的页脚的虚线。更多的帮助?请? –

0

如果你能删除position: absolute所有你需要做的就是明确你的页脚脱身:

#footer { 
    clear: both; 
} 

both将避免元素浮动或向左(如#main)或右(如#sidebar )。

如果你只是想清楚#sidebar而不是#main,使用clear: right;

0

我建议你用固定的CSS继续之前固定的HTML代码中的所有错误。