似乎无法找到导航菜单布局的错误...它不在div容器的中心。顺便说一下,它不是原始的菜单,它是纯粹的css菜单,没有图形,但有相同的问题。因为我找不到有什么问题,所以我抓住了一个有效的例子,但是当我的代码中包含同样的问题时。
请帮忙......谢谢。
<html>
<head>
<title>Home</title>
</head>
<link href="home.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.11.0.min.js"></script>
<body>
<div id="container">
<div class="header-cont">
<div class="header">
<img src="images/header.png"></img>
<?php require ("testnavigation.php"); ?>
</div>
</div>
<div id="content-container1">
<div id="section-navigation">
<p>sidebar navigation</p>
</div>
<div id="content">
<p>contents here</p>
</div>
<div id="aside">
<h3>Aside heading</h3>
<p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit
esse molestie consequat, vel illum dolore eu feugiat nulla
facilisis at vero eros et accumsan.</p>
</div>
<div id="footer">Copyright © Site name, 20XX</div>
</div>
</div>
</body>
</html>
这是css
body {
//font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, Sans-Serif;
//font-size: 12px;
background: #0E2B43;
}
.header-cont {
width: 100%;
position: fixed;
top: 0px;
left: 0px;
}
.header > img {
horizontal-align: middle;
vertical-align: middle;
}
.header {
height: 122px;
background: #333;
//border: 1px solid #CCC;
width: 100%;
margin: 0px auto;
}
#container {
margin: 0 auto;
width: 100%;
//width: 966px;
background: #33FF99;
}
#header h1 {
margin: 0;
}
#content-container1 {
float: left;
width: 100%;
background-color: #e9eaed;
margin: 122px auto;
}
#content-container2 {
float: left;
width: 100%;
}
#content {
float: left;
width: 40%;
padding: 20px 0;
margin: 0 0 0 2%;
}
#content h2 {
margin: 0;
}
#aside {
float: right;
width: 35%;
padding: 20px 0;
margin: 0 2% 0 0;
display: inline;
}
#aside h3 {
margin: 0;
}
#footer {
clear: both;
background: #ccc;
text-align: right;
padding: 20px;
height: 1%;
}
#content h1 { //
margin: 1em 0 0.5em 0;
color: #343434;
font-weight: normal;
font-size: 30px;
line-height: 40px; //
font-family: 'Orienta', sans-serif;
border-bottom: 1px solid rgba(53, 86, 129, 0.3);
}
/* These are used on the sidebar */
#section-navigation {
float: left;
width: 16%;
padding: 20px 0;
margin: 0 2%;
display: inline; //
background-color: #ccc;
}
#section-navigation ul {
margin: 0;
padding: 0;
}
#section-navigation ul li {
margin: 0 0 1em;
padding: 0;
list-style-type: none;
}
#section-navigation li a {
display: block;
margin: 0 0px 0 0;
width: auto;
text-decoration: none;
}
/* These are used on the sidebar */
/* These are used on the header navigation */
.clearer {
clear: both;
}
#navigation-row {
background: #aeb5b8 url("images/navigation-bg.gif") repeat-x left top;
height: 38px;
border-left: solid 1px #818b8f;
border-right: solid 1px #818b8f;
//width: 920px;
width: 100%;
margin: 0px auto;
}
ul#navigation {
display: block;
float: left;
list-style: none;
background: url("images/nav-spacer.gif") repeat-y -1px top;
height: 38px;
}
ul#navigation li {
display: block;
float: left;
background: url("images/nav-spacer.gif") repeat-y right top;
height: 38px;
padding-right: 2px;
}
ul#navigation li a {
display: block;
float: left;
line-height: 38px;
padding: 0px 20px;
font-family: Verdana;
font-size: 14px;
color: #313a3e;
text-decoration: none;
// text-transform: uppercase;
letter-spacing: -1px;
}
ul#navigation li a:hover, ul#navigation li a.active {
background: url("images/nav-bg-hover.gif") repeat-x left top;
}
这是navigation.php
<div id="navigation-row">
<ul id="navigation">
<li><a href="Home.php">Home</a></li>
<li><a href="#">Account</a></li>
<li><a href="logout.php">Logout</font></a></li>
</ul>
<div class="search">
<form action="search.php" method="POST">
<input name="search" type="text" maxlength="30" class="textfield"
value="search" />
</form>
</div>
<div class="clearer"></div>
</div>
答案 0 :(得分:1)
我刚刚删除了这两行
ul#navigation li a {
float: left; /* removed this */
line-height: 38px; /* removed this */
}
答案 1 :(得分:1)
我的猜测是,您的ul#navigation
继承了默认用户代理的样式表,Chrome中的样式表的边距为16px。如果您将margin: 0;
添加到该规则中,我认为您可能会得到您想要的内容。