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 trialZachary Jackson
Treehouse Project ReviewerVertical alignment issues with containers and floats/inline-blocks
I am having trouble getting items to align vertically in the main header for the Best City Guide CSS challenge. The link to the challenge is the Watch Video above. I also have included my index.html and style.css file to test with down below. I have a container of floated characters inside of a container within the main header. The page's name on the left side of the header "Best City Guide" is centered, but this is because it is the largest element in the container. The container is clearfixed and will take up as much room as it needs to. If I take the clearfix out everything will collapse. I have looked at older CSS content and some of the videos, but I am missing something somewhere. If anyone wants to take a look at my project I would appreciate it.
Zachary Jackson
Treehouse Project Reviewer<!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>
<div class="container-main-nav">
<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-main-nav clearfix-->
</div><!--/.container clearfix-->
</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">
<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>
<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é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 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><!--/.tertiary-->
<footer class="main-footer">
<span>©2015 Residents of The Best City Ever.</span>
</footer>
</body>
</html>
Steven Parker
231,248 PointsTo format your code in a code box, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. Or watch this video on code formatting.
But a much better way to share a project is to make a snapshot of your workspace and post the link to it here. This is particularly useful for a project like this one that relies on additional resources such as graphic elements.
Zachary Jackson
Treehouse Project ReviewerThanks Steven Parker for the information about formatting code. I completely missed that Markdown Cheatsheet reference.
1 Answer
Steven Parker
231,248 PointsAre you talking about how "Best City Guide" and the nav items are on different lines? To make them vertically aligned, you can set ".name" to "float: left". And then you won't need to change the "display" property because floating it makes it not participate in normal positioning.
If that's not it, perhaps you could explain the issue in different terms.
Also, you might consider proceeding with the next few videos as they show sample formatting solutions which might answer your questions.
Zachary Jackson
Treehouse Project ReviewerYou are correct that I was talking about how the "Best City Guide" and the nav items are on different lines vertically. I will continue on to the solution video as suggested. While I knew those videos where there I was trying to avoid watching them somewhat until I finished with all or most of this project. However, I don't think there is any shame in continuing on if one is stuck especially if the video will help things click into place. Thanks again Mr Parker.
Zachary Jackson
Treehouse Project ReviewerZachary Jackson
Treehouse Project Reviewer