Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Kenny Parewijck
Kenny Parewijck
4,602 Points

css-basics - Clearfix doesn't work here.. How come?

Hi!

I am trying to reproduce the lake tahoe website from css-basics track. I am inserting the clearfix in the two column wrapper div so that the footer will clear.

Doing this by adding a group:after class in the css and adding this group class to the wrapper div (name for the div: content-two).

this is not working here.. I have tried to delete the group class and and just add a clear:both to the class : main-footer and this works fine then. BUT.. I would like an explanation why the clear fix won't work here..

Thanks already!

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Lake Tahoe</title>
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/style.css">
  </head>
  <body>
    <header id="top" class="main-header">
      <span class="title">Journey Through the Sierra Nevada Mountains</span>
      <h1>lake tahoe, california</h1>
      <img src="img/arrow.svg" class="arrow-img" />
    </header>
    <section class="total-wrapper" class="group">

      <section class="content-one">
          <p class="intro">
            Lake Tahoe is one of the most breathtaking attractions located in California.
            It's home to a number of ski resorts, summer outdoor recreation,
            and tourist attractions. Snow and skiing are a significant part
            of the area's reputation.
          </p>
          <p>
            <a class="callout" href="#more">Find out more</a>
          </p>
          <div class="wildlife-div">
            <h2>Check out all the Wildlife</h2>
            <p>
              As spawning season approaches, the fish acquire a humpback and protuberant jaw.
              After spawning, they die and their carcasses provide a feast
              for gatherings of <a href="#mink">mink</a>, <a href="#bears">bears</a>, and <a href="#bald eagles">bald eagles</a>.
            </p>
          </div>
          <p>
            <a href="#See the Wildlife" class="callout">See the Wildlife</a>
          </p>
      </section>

      <div class="content-two" class="group">
          <div class="pack-accordingly-div">
            <img src="img/mtn-landscape.jpg" alt="" />
            <h3>Pack Accordingly</h2>
            <p>
              One of most important things when it comes to traveling through the great outdoors is packing accordingly. Here are a few tips:
            </p>
            <ol>
              <li>Bring layers of clothing</li>
              <li>Pack sunscreen</li>
              <li>Carry extra water just in case</li>
              <li>Pack light</li>
            </ol>
          </div>
          <div class="tents-to-resorts-div">
            <img src="img/resort.jpg" alt="" />
            <h3>From Tents to Resorts</h2>
            <p>
              Lake Tahoe is full of wonderful places to stay. You have the ability to sleep in the outdoors in a tent, or relax like a king at a five star resort. Here are our top three resorts:
            </p>
            <ul>
              <li><a href="#Lake Tahoe Resort Hotel">Lake Tahoe Resort Hotel</a></li>
              <li><a href="#South Lake Tahoe Resorts">South Lake Tahoe Resorts</a></li>
              <li><a href="#Tahoe Ski Resort Lodging">Tahoe Ski Resort Lodging</a></li>
            </ul>
          </div>
      </div>
    </section>

      <footer class="main-footer">
          <p>
            All rights reserved to the state of <a href="#bttop">California</a>.
          </p>
          <p>
            <a href="#top">Back to top »</a>
          </p>
      </footer>

  </body>
</html>
/* Web Fonts -------------------- */

@font-face {
  font-family: 'Abolition Regular';
  src: url('../fonts/abolition-regular-webfont.eot');
  src: url('../fonts/abolition-regular-webfont.eot?#iefix') format('embedded-opentype'),
       url('../fonts/abolition-regular-webfont.woff') format('woff'),
       url('../fonts/abolition-regular-webfont.ttf') format('truetype');
}



/* Basic styles -------------------- */

* {
  margin: 0px;
  padding:0px;
  border: 0px;
  box-sizing: border-box;
}

body {
  font: 1rem/1.5 "helvetica Neue", helvetica, arial, sans-serif;
  color: #878787;
}

img {
  max-width: 100%;
  margin-bottom: 20px;
  border-radius: 10px;
}

a {
  text-decoration: none;
}

h1,h2 {
  font-family: "abolition regular", helvetica, arial, sans-serif;
}

h1 {
  color: white;
  margin: 0;
  padding: 0;
  font-weight: normal;
  font-size: 5.6rem;
  line-height: 1.3;
  text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.8);
  margin: 12px 0 0;
}

h2 {
  font-size: 3rem;
  font-weight: normal;
  line-height: 1.1;
  margin-bottom: 2rem;
}

h3 {
  font-size: 1.3rem;
  color: #48525c;
  line-height: 1.2;
  margin-bottom: 1.8rem;
}

ul,ol {
  margin: 30px 0;
}

li {
  margin-bottom: 10px;
}

/* Pseudo classes styles -------------------- */

a:link {
  color: rgb(255, 169, 73);
}

a:visited {
  color: lightblue;
}

a:hover {
  color: rgba(255, 169, 73, .4);
}

a:active {
  color: lightcoral;
}



/* Class styles -------------------- */

.main-header {
    background-image: url(../img/mountains.jpg);
    background-repeat: no-repeat;
    background-size: cover;
}

.content-one, .main-footer, .main-header {
  text-align: center;
}

.wildlife-div {
  text-align: left;
}

.title { /* span bovenaan boven de h1 */
  font: 1.8rem/1.4 "helvetica neue", helvetica, arial, sans-serif;
  color: white;
  font-weight: 200;
  border-bottom: 2px white solid;
  padding-bottom: 8px;
  letter-spacing: 0.3px;
}

.arrow-img {
  width: 50px;
  margin-top: 150px;
}

.intro {
  font-size: 1.25rem;
  line-height: 1.5;
}

.callout {
  border-bottom: 2px solid;
  padding: 7px;
  font-size: 1.25rem;
}



/* Layout styles -------------------- */

.main-header {
  width: 100%;
  height: 850px;
  padding-top: 170px;
}

.total-wrapper {
  width: 75%;
  padding-left: 50px;
  padding-right: 50px;
  max-width: 960px;
  margin: auto;
}

.wildlife-div {
  padding: 18% 24%;
  margin:0;
  border: 0;
  color: white;
  background: #434a52 url('../img/bear.jpg') no-repeat center;
  background-size: cover;
  border-radius: 10px;
}

.pack-accordingly-div {
  border: 1px solid red;
  width: 45%;
  float: left;
}

.tents-to-resorts-div {
  border: 1px solid blue;
  width: 45%;
  float: right;
}

/* Layout styles -------------------- */



.group:after {
  content: "";
  display: table;
  clear: both;
}

set the class group like this

  <div class="content-two group">

2 Answers

Set classes in html without two "class" keywords, separate them with a single space:

<div class="style-one group"> 

If you still have a problem try using this for you clearfix css:

.group:after { 
   content: " "; 
   visibility: hidden; 
   display: block; 
   height: 0; 
   clear: both;
}
Kenny Parewijck
Kenny Parewijck
4,602 Points

allright!

removing the second 'class' was the answer. Thanks!