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 CSS Basics (2014) Basic Layout box-sizing and max-width

elie kfouri
elie kfouri
2,389 Points

what did we use to center the image properly in this video?

hey, I was wondering what styles did we use to center the image perfectly

2 Answers

hello. If you are talking about the resort and mtn-landscape images then they were centered using the

margin: auto;

in the

.primary-content, 
.secondary-content {
    width: 75%;
    padding-left: 50px;
    padding-right: 50px;
    margin: auto;
    max-width: 900px;
}

hope this helps :)

Austin Whipple
Austin Whipple
29,725 Points

Hi Elie,

Looks like you'll want to use:

img {
   max-width: 100%;
}

That will prevent the images from flowing outside of the container element's boundaries and keep it centered with the rest of the content.