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

CSS How to Make a Website Styling Web Pages and Navigation Style the Portfolio

Elizabeth Hodgson
Elizabeth Hodgson
1,642 Points

Float left not working

The photos are still just appearing in one column, even though I followed the code to the T.

Hi Elizabeth :)

Can you post your code including css...

This is the code that will make them into a row....

/*This is from when i did the course*/

#gallery li {
    float: left;
    width: 45%;
    margin: 2.5%;
}

/*This is the clear fix to put in responsive.css to break into two rows*/

@media screen and (min-width: 480px) {

    #gallery li {
        width: 28.3333%;
    }

    #gallery li:nth-child(3n) {
        clear: left;
    }

}

/*You should then have two colums on mobile and 3 on Desktop with 2 images on top row and 3 on bottom :) */

Hope this helps Craig!

If not please post code

Elizabeth Hodgson
Elizabeth Hodgson
1,642 Points

Hi Craig,

Thanks so much for your note. Here is my code:

gallery {

margin: 0; padding: 0; list-style: none; }

gallery li {

float: left; width: 45%; margin: 2.5%; background-color: #f5f5f5; color: #bdc3c7; }

Also, tried the code you used below. Either way, it still renders as a single column. Liz

Elizabeth Hodgson
Elizabeth Hodgson
1,642 Points

Thanks so much for your response. Feeling a little silly now. The problem was with my HTML. Forgot to add an id (blushing).

We all do it Elizabeth, we will keep it on a need to know basis lol .... :) Good luck with rest of course if you want to Tag me in any future questions id me happy to help just drop an "@" before typing my name and ill get a notification an help as best I can...

Craig

3 Answers

pi R
pi R
12,720 Points

Hi Elizabeth, can you please post your code ? So we can figure out what's the problem ;) (look the video "Tips for asking questions", on the right, it will tell you how to do it)

Hi Elizabeth :)

Have you managed to get to the bottom of this? If not let me know and help you get all your code posted so we can skim over it and check for any errors as the problem could be a result of something elsewhere in the code...

Craig

Hi Elizabeth, I am having the same problem as you had when you were posting this question. I added id and my photos are stacked on top of each other. any help will be appreciated

thanks in advance