Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,712 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.