我有三級div的我的工作:主要,這是其他兩個容器,頭只由現在的圖像,並且導航其中有一些鏈接。現在,我無法直接在導航div下面定位導航div,它們之間總是有一行主div。有關如何去做這件事的任何建議?CSS - 定位div的
HTML:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title></title>
</head>
<body>
<div class="main">
<div class="header">
<img src="images/logo.jpg" />
</div>
<div class="navigation"><ul id = "linkbar">
<li><a href="">Home</a></li>
<li><a href="">Guestbook</a></li>
<li><a href="">Contact</a></li>
<li><a href="">Quotes</a></li>
<li><a href="">Links</a></li></ul>
</div>
</div>
</body>
</html>
CSS:
body {
background-color: gray;
margin:0px;
padding:0px;
}
.header {
background-color:white;
}
.main {
background-color: yellow;
text-align: center;
width: 900px;
margin: auto;
}
a:link {color:white; text-decoration:none;} /* unvisited link */
a:visited {color:white; text-decoration:none;} /* visited link */
a:hover {color:red; text-decoration:underline;} /* mouse over link*/
a:active {color:red; text-decoration:underline;} /* selected link */
.navigation {
text-align: center;
background-color: f8901f;
}
#linkbar li {
margin: 0px 20px 0px 20px;
padding: 11px 0px 10px 0px;
list-style-type: none;
display: inline;
line-height: 2.5em;
}
做到了!謝謝! – tim 2011-04-15 22:22:44