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 trialbaderbouta
7,804 PointsWondering why my "Best City Guide" text is not aligning with my nav-bar...
I'm really wondering why my "Best City Guide" is not aligning... correctly, It's driving me nuts.
Here's the code, would love a hand.
<!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>
<div class="main-wrapper">
<header class="main-header">
<div class="container">
<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>
</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="column-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>
<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-->
</div>
</div>
<footer class="main-footer">
<span>©2015 Residents of The Best City Ever.</span>
</footer>
</body>
</html>
/* =================================
Base Element Styles
==================================== */
* {
box-sizing: border-box;
}
body {
font-family: 'Varela Round', sans-serif;
line-height: 1.6;
color: #3a3a3a;
}
p {
font-size: .95em;
margin-bottom: 1.8em;
}
h2,
h3,
a {
color: #093a58;
}
h2,
h3 {
margin-top: 0;
}
a {
text-decoration: none;
}
/* =================================
Base Layout Styles
==================================== */
/* ---- Navigation ---- */
.name {
font-size: 1.25em;
margin: 0;
}
.name a,
.main-nav a {
text-align: center;
}
.main-nav a {
font-size: .95em;
color: #3acec2;
text-transform: uppercase;
}
.main-nav a:hover {
color: #093a58;
}
.container {
width: 80%;
padding: 20px 20px;
text-align: center;
display: inline;
}
/* ---- Layout Containers ---- */
.banner {
color: #fff;
background: #3acec2;
margin: 0 auto;
margin-bottom: 3em;
text-align: center;
padding: 20px 20px;
}
.banner span {
font-size: 1.25em;
}
.col {
margin-bottom: 35px;
padding-left: 1em;
padding-right: 1em;
}
/* .primary {
float:left;
}
.secondary {
text-align: center;
}
.tertiary {
text-align: center;
} */
.main-footer {
background: #d9e4ea;
padding: 2em 0;
margin-top: 30px;
text-align: center;
}
/* ---- Page Elements ---- */
.headline {
margin-bottom: 0;
}
.logo {
width: 190px;
}
/* =================================
Media Queries
==================================== */
@media (min-width: 769px) {
h1 {
margin: 0;
}
/* ---- Navigation ---- */
.main-header {
padding: 3em 1em 3em 1em;
}
.name {
float: left;
font-size: 2em;
display: inline-block;
margin: 0;
}
.main-nav {
display: inline-block;
float: right;
}
.main-nav li{
display: inline-block;
padding-left: 20px;
}
/* ---- Layout containers ---- */
.main-wrapper {
min-height: calc(100vh - 200px);
}
.banner {
color: #fff;
background: #3acec2;
margin: 0 auto;
margin-bottom: 3em;
text-align: center;
padding: 5em 5em;
}
.headline {
font-size: 3em;
}
.tagline {
font-size: 10em;
}
/* ---- Columns ---- */
.col {
margin-left: 5px;
margin-right: 5px;
width: 90%;
}
.primary {
float: left;
width: 33%;
}
.secondary {
float: left;
width: 30%;
}
.tertiary {
float: right;
width: 33%;
}
/* ---- Float clearfix ---- */
.clearfix::after {
content: " ";
display: table;
clear: both;
}
}
1 Answer
Austin Whipple
29,725 PointsIt looks like the container
in which you've put your heading is collapsing due to floats. This can cause weird alignment problems.
I'd recommend starting the diagnostic process by either removing the float
declarations entirely or adding the clearfix
class to that container
and adjusting as necessary.