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

HTML How to Make a Website Responsive Web Design and Testing Adjust the Profile Page and Header

Andrei Duhanes
Andrei Duhanes
14,155 Points

Why when adding responsive css code (min-width: 660px) for my nav bar it rearranges my listed elements chaotically?

I've added @media screen and (min-width: 660px) for my <nav> tag like this: nav { background:none; float: right; font-size: 1.125em; width: 45%; margin-right: 5%; text-align: right; }

The result is: The nav text on the right side (which is correct) but with the background messed up, and one of my <li> items ( a picture) has been moved into the header.

I appreciate the help!

2 Answers

Daniel Stopka
Daniel Stopka
13,520 Points

Hi, by setting float:right; you take content from normal flow, so elements that are bellow will try to take place in normal flow...

There is a way to avoid this behaviour, it is called clearfix:

.group::after {
   content: " ";
   display: table;
   clear: both;
}

You have to add class group to the floated element. You can find some information here: https://teamtreehouse.com/community/explain-clearfix

Andrei Duhanes
Andrei Duhanes
14,155 Points

Hi Daniel,

Thank you very much for your help.