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

Kyle Shamblin
Kyle Shamblin
9,945 Points

My Two-Column Layout Challenge Solution (Tips or Advice?)

Challenge instructions

Target the two columns inside the main container to display two equal-width columns. Display both columns horizontally so that they appear side by side on the same line. You're building the column layout using a mobile first approach, so the layout styles should apply to large screens only.

Here's my solution. I'd love to hear any advice on how I could do it better.

.col {
  width: 50%;
  padding: 2em 1em;
  display: inline-block;
  margin: 0 auto;
  }

  .secondary {
  float: right;
  display: inline-block;
}
<div class="container"> 

  <div class="primary col">
    <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><!--/.primary-->

  <div class="secondary col">
    <h2>Great food</h2>
    <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>
    <p> Fruitcake jelly-o croissant souffl&#233;. Biscuit jujubes drag&#233;e. Sesame snaps tootsie roll chocolate bar cake tart macaroon pudding. Ice cream gummies jujubes cupcake. Cake marshmallow cookie lollipop tart.</p>
  </div><!--/.secondary-->

</div><!--/.container-->
Dale Severude
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,349 Points

Hey your solution works!

In the video he only targets the col class which is simpler.

Setting display to inline-block in the secondary class is redundant, as it is already set in the col class.

If you set the width to 49%, you wouldn't have to target the secondary class at all.

But your solution works. I would only get rid of the redundant code.

1 Answer

Kyle Shamblin
Kyle Shamblin
9,945 Points

Thanks for the tips, Dale. They were very helpful!