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 trialCullen Kuch
Front End Web Development Techdegree Graduate 20,492 PointsFooter won't collapse with clearfix
Hi all! I see that others may have had a similar issue but after sorting through their questions and responses I still haven't had any luck. I've added the clearfix to my HTML and it worked for my header but my footer remains expanded in the two wider displays other than the mobile layout. Is it a matter of where my float clearfix is positioned within the media queries? I've tried moving it out of them but still no luck. I even added another clearfix property to the footer element directly in HTML. Any help would be greatly appreciated!
@media (min-width: 769px) {
.container {
width: 90%;
margin: 0 auto;
}
.name,
.col {
float: left;
}
.primary,
.secondary {
width: 50%;
}
.main-nav {
float: right;
}
.main-nav li {
display: inline-block;
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%;
}
}
2 Answers
KRIS NIKOLAISEN
54,971 PointsI added two closing div tags to your html and it appears to be working:
</div><!--/.tertiary-->
</div><!-- add this closing tag -->
<div class="container">
<footer class="main-footer clearfix">
<span>©2015 Residents of The Best City Ever.</span>
</footer>
</div><!-- add this closing tag-->
Cullen Kuch
Front End Web Development Techdegree Graduate 20,492 PointsUgh, there it is! Thanks so much Kris!
Cullen Kuch
Front End Web Development Techdegree Graduate 20,492 PointsSure thing!
<!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>
</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="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 class="container">
<footer class="main-footer clearfix">
<span>©2015 Residents of The Best City Ever.</span>
</footer>
</body>
</html>
KRIS NIKOLAISEN
54,971 PointsKRIS NIKOLAISEN
54,971 PointsCan you post the html?