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

Justin Hicks
Justin Hicks
14,290 Points

css layout basics columns not cooperating

The layout challenge I did my way and then watched the video to see if that would help me get the columns right but even comparing my code with the code in the video I still cant get the columns to cooperate. Any help is appreciteted!

Justin Hicks
Justin Hicks
14,290 Points

Sorry forgot the code lol

/* ================================= 
  Media Queries
==================================== */

@media (min-width: 769px) {

 .container {
    width: 90%;
    margin: 0 auto;
}

.main-header {
  display: inline;
  margin: 0;
  padding: 2px;
} 

.name, 
.col {
  float: left;
}

.name a,
.main-nav a {
    text-align: center;
  display: inline-block;
  padding: 10px 15px;
}

.primary,
.secondary {
  width: 50%;
}

.main-nav li {
  display: inline-block;
  float: right;
  margin-left: 15px;
}

.tagline {
  font-size: 1.4em;
}



}
    /* ---- Float clearfix ---- */

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

}

@media (min-width: 1025px) {

.container {
  width: 80%;
  max-width: 1150px;
}

.primary {
  width: 40%;
}

.secondary,
.tertiary {
  width: 30%;
}

}```

7 Answers

Idan Melamed
Idan Melamed
16,285 Points

Noticed another thing... The clearfix class should be in the parent container...

So try switching

<div class="secondary col">
<div class="container clearfix">

With

<div class="container clearfix">
  <div class="secondary col">
Justin Hicks
Justin Hicks
14,290 Points

That did provide a different result but its still not corrected entirely, but at 5:20 AM I'm going to take a break from it lol. Thank you for your helpful suggestions.

Justin Hicks
Justin Hicks
14,290 Points

I finally figured it all out, I had left off the closing div for the .secondary but I also had left out 2 closing curly braces in the css which was causing my problems. Thanks for your help Idan, you made me realize i was making typos :-)

Idan Melamed
Idan Melamed
16,285 Points

Hi Justin, Did you add the class .clearfix to the parent container?

Justin Hicks
Justin Hicks
14,290 Points

I did, if you like I can add the html code as well?

Justin Hicks
Justin Hicks
14,290 Points
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Best City Guide</title>
    <link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/style.css">
</head>
<body>

   <header class="main-header">
     <div class="container, clearfix">
      <h1 class="name"><a href="#">Best City Guide</a></h1>
      <ul class="main-nav">
        <li><a href="#">ice cream</a></li>
        <li><a href="#">donuts</a></li>
        <li><a href="#">tea</a></li>
        <li><a href="#">coffee</a></li>
      </ul>
    </div><!---- Container ---->   
  </header><!--/.main-header-->   

    <div class="banner">
        <img class="logo" src="img/city-logo.svg" alt="City">
        <h1 class="headline">The Best City</h1>
        <span class="tagline">The best drinks and eats in the best city ever.</span>   
    </div><!--/.banner-->


    <div class="secondary col">
    <div class="container, clearfix">
      <h2>Welcome!</h2>
      <p>Everything in this city is worth waiting in line for.</p>
      <p>Cupcake ipsum dolor sit. Amet chocolate cake gummies jelly beans candy bonbon brownie candy. Gingerbread powder muffin. Icing cotton candy. Croissant icing pie ice cream brownie I love cheesecake cookie. Pastry chocolate pastry jelly croissant.</p>
      <p>Cake sesame snaps sweet tart candy canes tiramisu I love oat cake chocolate bar. Jelly beans pastry brownie sugar plum pastry bear claw tiramisu tootsie roll. Tootsie roll wafer I love chocolate donuts.</p>  

    <div class="primary col">
      <h2>Great food</h2>
      <img class="feat-img" src="img/treats.svg" alt="Drinks and eats">
      <p>Croissant macaroon pie brownie. Cookie marshmallow liquorice gingerbread caramels toffee I love chocolate. Wafer lollipop dessert. Bonbon jelly beans pudding dessert sugar plum. Marzipan toffee drag&#233;e chocolate bar candy toffee pudding I love. Gummi bears pie gingerbread lollipop.</p> 
    </div><!--/.primary-->

    <div class="tertiary col">
      <h2>How to get here</h2>
      <p><strong>Plane: </strong>Tiramisu caramels gummies chupa chups lollipop muffin. Jujubes chocolate caramels cheesecake brownie lollipop drag&#233;e cheesecake.</p>
      <p><strong>Train: </strong>Pie apple pie pudding I love wafer toffee liquorice sesame snaps lemon drops. Lollipop gummi bears dessert muffin I love fruitcake toffee pie.</p>
      <p><strong>Car: </strong>Jelly cotton candy bonbon jelly-o jelly-o I love. I love sugar plum chocolate cake pie I love pastry liquorice.</p>
     </div><!----/Container---->
  </div><!--/.tertiary-->



    <footer class="main-footer">
        <span>&copy;2015 Residents of The Best City Ever.</span>
    </footer>

</body>
</html>```
Justin Hicks
Justin Hicks
14,290 Points

wow sorry about the mess I just made adding code

Idan Melamed
Idan Melamed
16,285 Points

one small syntax error I noticed is this:

<div class="container, clearfix">
.
.
.
<div class="container, clearfix">

Try removing the commas and see if it helps.

Justin Hicks
Justin Hicks
14,290 Points

I've tried it with and without but it still does the same thing. Even using developer tools to inspect, it doesnt make sense why its behaving the way it is.

Justin Hicks
Justin Hicks
14,290 Points

I just noticed that when i change the width in a small section that controls the primary and secondary column width the columns are not expanding into 2 instead they stay stacked leaving the width to 50% with the rest being left to the html element. even the footer only takes 50% up?

.primary,
.secondary {
  width: 50%;
}```