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 trialRachael Farquharson
5,234 PointsNavigation gets messed up when applying float: right to media queries
When I add float: right to the navigation in the responsive media queries, it messes up the links. What have I done wrong?
@media screen and (min-width: 660px) {
/************************************
PAGE: HEADER
***********************************/
nav {
background: none;
float: right;
font-size: 1.125em;
margin-right: 5%;
text-align: right;
width: 45%;
}
#logo {
float: left;
margin-left: 5%;
text-align: left;
width: 45%;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 0.825em;
margin-bottom: 20px;
}
header {
border-bottom:: 5px solid #006dcc;
}
}
/************************************
header
***********************************/
#header {
float:left;
margin: 0 0 30px 0;
padding: 5px 0 0 0;
width: 100%;
color: #FFFFFF;
}
#logo {
max-width: 940px;
text-align: center;
margin: 0;
}
header {
background: #6abaff;
padding: 40px 0 0;
}
header a {
color: white;
}
/* site body */
#wrapper {
max-width: 940px;
margin: 0 auto;
padding: 5% 5%;
}
body {
font-family: 'Merriweather', serif; font-weight: 400;
background-color: #FFFFFF;
}
/* font styling */
a, p a:visited {
color: #4dacff;
}
a:hover {
color: #fff;
}
a, a:visited {
text-decoration: none;
}
h1 {
font-family: 'Open Sans', sans-serif;
margin: 15px 0;
font-size: 1.75em;
line-height: 0.8em;
font-weight: normal;
}
h2 {
font-family: 'Merriweather', serif; font-weight: 400; font-style:italic ;
font-size: 1em;
margin: -5px 0 0;
}
h3, h4, p {
font-family: 'Merriweather', serif; font-weight: 400;
}
h3 {
margin: 0 0 1em 0;
}
/************************************
NAVIGATION
***********************************/
nav {
text-align:center;
padding: 10px 0;
margin: 50px 0 0;
background-color: #4dacff;
}
nav a:hover {
color: #006dcc;
}
nav a.whaat {
font-weight: bold;
color: #006dcc;
}
nav ul {
list-style: none;
margin: 0 10px;
padding: 0;
}
nav li {
display: inline-block;
}
nav a {
padding: 15px 10px;
color: white;
}
/************************************
FOOTER
***********************************/
footer {
font-size: 0.75em;
text-align:center;
clear: both;
padding-top: 50px;
padding-bottom: 50px;
}
.social-icon {
width: 20px;
height: 20px;
margin: 0 5px;
}
/************************************
gallery
***********************************/
img {
max-width: 100%;
}
#gallery {
margin: 0;
padding: 0;
list-style: none;
}
#gallery li a p {
margin: 0;
padding: 5%;
font-size: 0.75em;
color: #bdc3c7;
}
#gallery li {
float: left;
width: 45%;
margin: 2.5%;
background-color: #f5f5f5;
color: #bdc3c7;
}
/************************************
`PAGE: ABOUT
***********************************/
.profile-photo {
display: block;
max-width: 80%;
max-height: 80%;
margin: 0 auto 30px;
border-radius: 80%;
}
/************************************
`PAGE: CONTACT
***********************************/
.contact-info {
list-style: none;
padding: 0;
margin: 0;
font-size: 0.9em;
}
.contact-info a {
display: block;
min-height: 20px;
background-repeat: no-repeat;
background-size: 20px 20px;
padding: 0 0 0 30px;
margin: 0 0 10px;
}
.contact-info li.phone a {
background-image: url('../img/phone.png');
}
.contact-info li.mail a {
background-image: url('../img/mail.png');
}
.contact-info li.twitter a {
background-image: url('../img/twitter.png');
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rachael Farquharson | Designer</title>
<link rel="stylesheet" href="css/normalize.css">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,400italic,700italic|Lora:400,400italic|Merriweather:400,700,700italic,400italic,300italic,900italic,900' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/responsive.css">
</head>
<body>
<header>
<a href="index.html" id="logo">
<h1>Rachael Farquharson</h1>
<h2>Graphic Designer</h2>
</a>
<nav>
<ul>
<li><a href="index.html">Portfolio</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html" class="whaat">Contact</a></li>
</ul>
</nav>
</header>
<div id="wrapper">
<section id="primary">
<h3>General Information</h3>
<p>Please only use phone contact for urgent matters, otherwise Twitter and email are ok</p>
</section>
<section id="secondary">
<h3>Contact details</h3>
<ul class="contact-info">
<li class="phone"><a href="tel:555-5322">555-5322</a></li>
<li class="mail"><a href="mailto:hellorachael.com">hellorachael.com</a></li>
<li class="twitter"><a href="http://twitter.com/intent/tweet?screen_name=nihaorachael">@hellorachael</a></li>
</ul>
</section>
<footer>
<a href="http://hellorachael.com"><img src="img/twitter.png" alt="twitter" class="social-icon"></a>
<a href="http://hellorachael.com"><img src="img/facebook.png" alt="facebook" class="social-icon"></a>
<p>© 2016 Rachael Farquharson.</p>
</footer>
</div>
</body>
</html>
2 Answers
Steven Parker
231,269 PointsFor starters, your header could use a "clearfix":
header::after {
content: "";
clear: both;
display: block;
}
There's probably a few more thinks to tweak, but that will make things visible again.
Also notice that you have two colons following border-bottom in the media query rule for header.
Caio Moretti Marques
Courses Plus Student 27,922 PointsI found this rule:
header { border-bottom:: 5px solid #006dcc; }
Can you see you have an extra colon after the border-bottom property? Try to fix and check if it works.
Rachael Farquharson
5,234 PointsRachael Farquharson
5,234 PointsThank you so much for that. Couldn't figure it out. I am not familiar with this pseudo element so I will study it now. Cheers!
Ryan Field
Courses Plus Student 21,242 PointsRyan Field
Courses Plus Student 21,242 PointsJust remember that any time you float something left or right, you are taking out of the document flow and the rest of your HTML will act as if it has no height or width. The clearfix basically adds an element after it that clears both (left and right) and cause any subsequent elements to align properly.