我想做一個3列的網站,但我似乎無法得到正確的導航顯示正確。它總是顯示在其他div下面。有人可以告訴我爲什麼會發生這種情況,以及它如何解決?浮動divs的問題
這裏是CSS:
body {
background-image:url('images/background.png');
background: no-repeat center center fix;
background-size: cover;
background-attachment: fixed;
}
p {
margin: 0px;
color: #231f20;
font-size: 16px;
font-family: "Garamond Premier Pro", serif;
text-align: left;
}
h1 {
margin: 0px;
color: #231f20;
display: inline-block;
text-align: center;
font-size: 24px;
font-family: "Myriad Pro", sans serif;
}
#container {
margin-left: auto;
margin-right: auto;
width: 960px;
height: 750px;
}
#header {
width: 960px;
height: 100px;
}
#marquee {
width: 960px;
height: 30px;
font-size: 24px;
background-color: #bc34ba;
font-family: "Garamond Premier Pro", serif;
}
#topnav {
border-bottom: 1px #000 solid;
margin: 0px;
padding: 0px 0px 0px 0px;
width: 960px;
height: 20px;
background-color: fed450;
#leftnav {
margin: 0px;
font-family: "Century Gothic", sans serif;
float: left;
width: 160px;
background-color: f58025;
text-align: left;
height: 580px;
}
#body {
margin: 0px;
border-right: 1px dashed #694717;
width: 640px;
height: 580px;
margin: auto;
padding: 10px 0px 0px 10px;
background-color: d80074;
}
#rightnav {
margin: 0px;
font-family: "Century Gothic", sans serif;
float: right;
width: 160px;
background-color: c1d82f;
text-align: right;
height: 580px;
}
#footer {
width: 960px;
height: 20px;
text-align: center;
clear: both;
}
下面是HTML:
<div id="container">
<div id="header"></div>
<div id="marquee"></div>
<div id="topnav"></div>
<div id="leftnav"></div>
<div id="body">
<h1>Title<h1>
<br>
<p>This is where the content is.</p>
</div>
<div id="rightnav"></div>
<div id="footer"></div>
</div>
謝謝你幫助我。你可能會猜到,這是我的第一個網站,我明白它肯定可以使用工作。 – user2532869
哦,沒問題。我們都和你在同一個地方。學習的最佳方式是通過試驗和錯誤:)掛在那裏,很快就會成爲你的第二天性。 – Chris78