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 trialElena Paraschiv
9,938 Pointswhy did Gill float the .col:last-child{ float: right; }
i notice in my browser that even if I add this
.col:last-child{
float: right;
}
it leads to the same results as adding only this:
.col {
padding: 30px;
float: left; /*you need to give a width to columns to float 'em*/
width: 30%;
}
Can someone please clarify why did Gill add float:right to the last column?
2 Answers
Jeff Lemay
14,268 PointsI would assume it has something to do with how browsers handle percentages.
If each column is supposed to be one-third of the width and your width is 1000px, each column should be 333.3px but we can't use partial pixels. So in this case, you might be left with an extra pixel because each column goes 333px (333x3=999). By floating the last column to the right, you ensure that your row of columns will appear to fill the full width.
Elena Paraschiv
9,938 PointsThat makes sense. Thanks Jeff :)