我正在使用网格960并且无法使用clearfix,但是如果我在元素上使用clear:both
,那么我可以获得所需的效果。我宁愿使用clearfix,因为我觉得它更可靠(通常)。
在下面的代码中,标题部分有一个左侧徽标区域和一个右侧横幅区域,然后在其下方应该是导航栏。
此导航栏是我遇到困难的元素。如果我将style="clear:both;"
添加到nav
元素,则可以正常使用。但是,如果我在header元素中使用clearfix,则它不起作用。
Here is the page that does not work (using clearfix)
Here is the page that works (using clear:both)
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>
我希望我没有做过任何明显错误的事情,但我看不到它。
答案 0 :(得分:0)
如果你在你的NAV元素之前放置一个空的DIV,并且有一个clearfix类,那么这应该可行。