Search code examples
cssclearfix

Clearfix class for HTML5Boilerplate is not being placed on a containing element


The website stinsonandassociates.com uses a clearfix on its mobile nav menu (seen at small screen widths). It is not working, but I am curious as to why the clearfix class I am applying (using HTML5Boilerplate) is not at least recognizing the clearfix properties. The desktop nav menu uses the same class and it works.

This is the HTML code:

<header>
<h1>Bob Stinson</h1>
<a href="/" title="Home Page">
    <img src="img/bobstinson_signature_v2.png" 
         alt="Bob Stinson signature" width="211" height="170" /></a>
</header>  
<nav id="topNav">
    <h2>Top Navigation</h2>
    <ul class="desktop clearfix">
      <li><a href="/" title="Home Page" class="current">Home</a></li>
      <li><a href="psychology" title="Psychology" 
              id="psychologyButton">Psychology</a></li>
      <li><a href="law" title="Law" id="lawButton">Law</a></li>
      <li><a href="about" title="About">About Us</a></li>
    </ul>
</nav>    
<nav class="mobile clearfix">   
    <ul>
      <li><a href="" title="Home Page">Home</a></li>
      <li><a href="psychology" title="PsychologyPage">Psychology</a></li>
      <li><a href="law" title="Law Page">Law</a></li>
      <li><a href="about" title="Law Page">About Us</a></li>
      <li><a href="contact" title="Law Page">Contact</a></li>
      <li><a href="legal" title="Law Page">Legal</a></li>
    </ul>
</nav> 

Solution

  • I copied your code and it seems to me that the closing bracket fixes your problem:

    List items contained in nav

    Above all list items are inside <nav class="mobile clearfix"> ... </nav>

    @media only screen and (min-width: 481px) {
      /* Style adjustments for viewports that meet the condition */
    
      /* Page Layout */
      ....
      /* About Us */
      .about h2 {
         text-align: left;
      }
    }  /* <--- i added this bracket */
    

    Does this fix your problem?