我正在使用网格 960 并且无法让 clearfix 工作,但是如果我clear:both
在元素上使用,那么我可以获得所需的效果。我更喜欢使用 clearfix,因为我发现它更可靠(通常)。
在下面的代码中,标题部分有一个左侧徽标区域和一个右侧横幅区域,然后在其下方应该是导航栏。
这个导航栏是我遇到困难的元素。如果我添加style="clear:both;"
到nav
元素,它工作正常。但是,如果我在 header 元素中使用 clearfix,它就不起作用。
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Home Page</title>
<link href="css/reset.css" rel="stylesheet" type="text/css" />
<link href="css/960_12_col.css" rel="stylesheet" type="text/css" />
<link href="css/site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container" class="container_12 ">
<header class="clearfix grid_12">
<div id="logoarea" class="grid_6 alpha">
<div id="title">
<h1>iContinuity Directory Services</h1>
</div>
<div id="logindisplay">
[ <a href="/Account/LogOn">Log On</a> ]
[ <a href="/Account/Register">Register</a> ]
</div>
</div><!-- end logoarea -->
<div id="headerbanner" class="grid_6 omega">
<p>this is the header banner area</p>
</div>
<nav class="">
<ul id="menu">
<li><a href="/">Home</a></li>
<li><a href="/Home/About">About</a></li>
</ul>
<form action="/Search/Search" class="navsearch" method="get">
<input class="textbox" id="search" name="search" type="text" value="" />
<input type="submit" value="Search" />
</form>
</nav>
</header>
<section id="main" class="grid_8 ">
<h2>Welcome to iContinuity Services</h2>
<p>
</p>
</section>
<aside id="sidebar" class="grid_4">
ontrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a lin
</aside>
<footer class="grid_12">
<p>this is the footer area</p>
</footer>
</div> <!-- end 960 grid container -->
</body>
</html>
我希望我没有做任何明显的错误,但我看不到。