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
Philip Ollas
5,705 PointsText displayed in as a table format(ref: Guil Hernandez Best City Guides)
Hi all,
I got a total black how I would align the text to be displayed in table format like in Best City. To keep a long story short I looked at the Best City Guide code and figured that to get it to be displayed I have to use the same html and css elements all the way from <div class="container clearfix"> to footer.
How ever I'm not 100% sure so that's why I would like to know if I was right and if not please feel free to correct me since it's important to get it right. Thank you for your answers in advance.
Please note that my intension is not to copy but to refresh my mind.
Here is the code part in full with CSS:
HTML & CSS
<div class="container clearfix">
<div class="secondary 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><!--/.secondary-->
<div class="primary col">
<h2>Great food</h2>
<figure>
<img class="icon-location" src="img/location.svg" alt="Location">
<img class="feat-img" src="img/treats.svg" alt="Drinks and eats">
<figcaption>
<h4>Featured Drinks & Eats!</h4>
Croissant macaroon pie brownie cookie marshmallow liquorice gingerbread caramels toffee.
</figcaption>
</figure>
<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é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é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 t coffee 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><!--/.tertiary-->
</div><!--/.container-->
figure {
margin: 0;
line-height: 0;
position:relative;
}
figcaption {
font-size: .9em;
line-height: 1.5;
color: #fff;
padding: 1em;
background: rgba(19,43,102, .85);
position: absolute;
bottom: 0;
width: 100%;
}
container {
width: 90%;
margin: 0 auto;
}
.clearfix::after {
content: " ";
display: table;
clear: both;
}
.primary,
.secondary {
width: 50%;
}
.col {
padding-right: 1em;
padding-left: 1em;
}
´´´
2 Answers
Zack Lee
Courses Plus Student 17,662 PointsIf I remember correctly, he was floating the div elements so they would display side by side, hence the need for the clearfix.
Try using "float: left;" on your div containers and include the clearfix class on them as well. Make sure they're at 50% width so they display side by side. Or a little less than 50% to account for margin/padding.
Philip Ollas
5,705 PointsAwesome, that makes sense. I'll take a shoot at that, hope it goes well. Thanks man!
Philip Ollas
5,705 PointsPhilip Ollas
5,705 PointsHey could you give a example of it, having a hard time visualizing how that should be done. Would appreciate that a lot.