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 Responsive Web Design and Testing Build a Three Column Layout

demiandaniel
demiandaniel
1,252 Points

Cannot manage to make three column work

I've finished the video and was following Nick each step, tho at the end I've not managed to make my 3 column work, as it's stuck on 2 :\

/************************ PAGE PORTFOLIO ************************/

gallery {

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

}

gallery li {

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

}

gallery li a p {

margin: 0;
padding: 5%;
font-size: 0.85em;
color: #bdc3c7;
height: 2em;

}

/************************
Two column layout
************************/
#primary {
    width: 50%;
    float: left;
}

#secondary {
    width: 40%;
    float: right;
}

/************************
PAGE: Portfolio
************************/

#gallery li {
    width: 28.3333%;
}
#gallery li:nth-child(4n) {
    clear:left;
}

}

Sahil Prajapati
Sahil Prajapati
8,524 Points

Hi

In the above code you are dividing the row into two columns:

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

So the total width becomes greater than 100%.

Change the width to 28.33% like this:

#gallery li{
 width: 28.33%;
margin: 2.5%;
}

And now the total width of the row will be 100%. (Now each li element will have a width of 33.33% (2.5% + 28.33%+ 2.5%).

1 Answer

demiandaniel
demiandaniel
1,252 Points

Many thanks, mate.