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
Ian Z
14,584 Pointsquestion about CSS float problem, and css image align problem
I am trying to float images so that i can make two columns, however when i float one left and the other right they just stack on each other and stay in one column.
here is CSS '''css .secondary-content{ width: 45%; padding-left:50px; padding-right: 50px; margin:auto; max-width:960px; text-align: center; ; }
.quote1, .quote3, .quote5{ float:left; } . quote2, .quote4, .quote6{ float:right; }
.group:after { content: ""; display: table; clear: both; }
'''
Also two images are skewed from center [IMG]http://i61.tinypic.com/vgk5k7.jpg[/IMG]
and
1 Answer
Nick Beukema
6,359 Points.secondary-content{
width: 45%;
padding-left:50px;
padding-right: 50px;
margin:auto;
max-width:960px;
text-align: center;
}
.quote1, .quote3, .quote5{
float:left;
}
. quote2, .quote4, .quote6{
float:right;
}
.group:after {
content: "";
display: table;
clear: both;
}
It looks like your images are messing with the size of your elements. I would try adding something like this:
.secondary-content img{
width:100%;
}
That way, when you're defining the width of the secondary-content, it will designate the width for the image as well.
Also, I think your padding inside the div element is pushing the images out. Keep in mind that the padding will insert space inside the element. When dealing with content inside of the element, the space available is:
the total width - padding on each side
So the image needs to fit in the space available for the percentage based width with padding to work correctly.
erdragerdragsson
Courses Plus Student 5,887 Pointserdragerdragsson
Courses Plus Student 5,887 Pointstry targeting the images then
margin: 0 auto;
i think thats gonna center them