我正在使用网格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>


我希望我没有做任何明显的错误,但我看不到。

最佳答案

如果在您的NAV元素之前放置一个空的DIV并带有clearfix类,则应该可以。

关于css - CSS 960网格clearfix不起作用,但clear:两者都起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11414273/

10-12 07:28