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!
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

Samuel Albert
8,839 PointsProblems in Media Query and floats
The page I'm trying to make for a desktop screen should have 2 columns in the body with additional information below it. Col 1 should be a photo. Col 2 should be an h2 element with an ul below it.
I've been able to get the desired effect outside of a media query, but have been unable to copy the results inside the query.
This is the code for the main "mobile" layout of the page in question:
.bios h2 {
font-family: 'Candal', sans-serif;
font-size: 100%;
color: #999;
margin: 0 auto 15px;
/* float: right;*/
/* margin-left: 50px;
margin-bottom: -10px;*/
}
.bios ul {
list-style: none;
border: 2px solid;
width: 45%;
margin: 0 auto 15px;
/* float: right;*/
/* margin-left: 50px;*/
}
.charimg {
/* float: left;*/
/* display: inline-block;*/
width: 45%;
margin: 0 auto 15px;
}
This is what I am attempting to do in my Media Query:
@media screen and (min-width: 480px) {
.charimg {
width: 50%;
float: left;
}
.bios,
h2 {
width: 45%;
float: right;
}
/* Clearfix
================================ */
.group::after {
content: " ";
display: table;
clear: both;
}
}
I am not sure what I am missing, on my screen, the .charimg has gone to the right, the h2 and .bio ul has gone to the middle and the text that is supposed to be below it acts like there is no clearfix.
Thank you for your help!
2 Answers

Zebhdiyah Pykosz
Courses Plus Student 1,021 PointsCould you supply the HTML?

Evans B. Ofori
Courses Plus Student 13,720 PointsHello Samuel, I have added example (below) the use of clearfix, have a look if it makes sense to you. The "clearfix" should be apply to the parent element.
<div class="wrapper group">
<div class="col1">
<img class="" src="">
</div>
<div class="col2">
<h2></h2>
<ul></ul>
</div>
</div><!-- end clearfix -->
@media screen and (min-width: 480px) {
.col1{
width: 50%;
float: left;
}
.col2{
width: 45%;
float: right;
}
}
Good luck, and let me know if you need more help.

Samuel Albert
8,839 PointsThat all makes sense, the problem seems to be the clearfix isn't working any longer. Perhaps I'm not putting that code in the right place? Right now it's in the media query under the .col1 and .col2 and I'm still having a problem with the floating being reversed. Col1 is showing up where col2 should be.
This is my updated HTML:
<div class="group">
<div class="charimg">
<img src="img/pangs.jpg" alt=" ">
</div>
<div class="bios">
<h2>General Information</h2>
<ul>
<li>Name: Alec Huber</li>
<li>Alias(es): Pangs</li>
<li>Age: 55</li>
<li>Race: Human, caucasian</li>
<li>Hair Color: Bald (brown)</li>
<li>Eye Color: Blue</li>
<li>Birth Place: Hamburg, Germany</li>
<li>Powers: Telekinesis, Mind Manipulation</li>
<li>Skills and Talents</li>
</ul>
</div>
</div><!-- end clearfix -->

Samuel Albert
8,839 PointsOkay, I fixed the problem and everything is looking good. It looks like I updated the wrong css file. Thanks for your response.
Samuel Albert
8,839 PointsSamuel Albert
8,839 PointsHere's the HTML
Zebhdiyah Pykosz
Courses Plus Student 1,021 PointsZebhdiyah Pykosz
Courses Plus Student 1,021 PointsIs this not the type of result you're looking for? http://jsbin.com/vovuxego/1/edit
Samuel Albert
8,839 PointsSamuel Albert
8,839 PointsYes, that's it! It's looking fine now, I think the problem was I updated the wrong css file for the media query so the second css file was overriding the first. Fixed now and it looks great! Thank you for the help.