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 Adding Pages to a Website Style New Pages

Warner Cyr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Warner Cyr
Front End Web Development Techdegree Graduate 21,047 Points

portfolio project: stage 7 - Adding pages to a Website

I'm trying to center Nick's photo but I can't get it to budge. I'm using the following css as shown in the video. Is there something else i should be looking at that won't allow me to center the photo? .profile-photo { display: block; max-width: 150px; margin: 0 auto 30px; border-radius: 100%; }

9 Answers

Are you refreshing the page because your css is correct

Desireé Bryant
Desireé Bryant
56,114 Points

Is the photo inside of another div and does that div have a width? That way the photo has a reference in order to center.

In your about.html does your code look like this?

<section>
       <img src="img/nick.jpg" alt="Photograph of Nick Pettit" class="profile-photo">
        <h3>About</h3>
        <p>Your paragraph</p>
      </section>

Make sure your closing tags are right and that you put your code in between <section> </section> elements Comment below what I said if you continue to have an error and I will try to further help you.

Warner Cyr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Warner Cyr
Front End Web Development Techdegree Graduate 21,047 Points

According to my HTML It's in the same Div as all these other elements which i have been able to position with no problems. Should I create a Div just for the image? All this content is on the about page, here is the html. The image in question is nick.jpg. Thanks for the help!

<div id="wrapper"> <section> <img src="img/nick.jpg" alt="Photograph of Nick Pettit" class="profile-photo"> <h3>About</h3> <p>Hi, I'm Nick Pettit! This is my design portfolio where I share all of my favorite work. When I'm not designing things, I enjoy exercising, playing video games, drinking good coffe, and more.</p> <p>If you'd like to follow me on Twitter, my username is <a href ="http://twitter.com/nickrp">@nickrp</a>.</p> </section> <footer> <a href="http://twitter.com/nickrp"><img src="img/twitter-wrap.png" alt="Twitter Logo" class="social-icon"></a> <a href="http://facebook.com/nickpettit"><img src="img/facebook-wrap.png" alt="Facebook Logo" class="social-icon"></a> <p>© 2014 Nick Pettit.</p> </footer> </div>

Travis Favaron
Travis Favaron
13,038 Points

Have you checked to make sure that you spelled the class name correctly in both CSS and in the HTML?

Warner Cyr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Warner Cyr
Front End Web Development Techdegree Graduate 21,047 Points

Nick Pettit

Hey Nick, sorry to bother you with this but I haven't been able to get a resolution for this and I'm desperate to figure it out. I'm wrapping up your HTML lesson on The Portfolio Project which I found to be very informative, however I can't figure out why your image isn't centering on the about page. According to the HTML it all seems to be in the same DIV. Below is the HTML and CSS.

Thanks Nick!

<div id="wrapper"> <section> <img src="img/nick.jpg" alt="Photograph of Nick Pettit" class="profile-photo"> <h3>About</h3> <p>Hi, I'm Nick Pettit! This is my design portfolio where I share all of my favorite work. When I'm not designing things, I enjoy exercising, playing video games, drinking good coffee, and more.</p> <p>If you'd like to follow me on Twitter, my username is <a href ="http://twitter.com/nickrp">@nickrp</a>.</p> </section>

/************************************* PAGE: ABOUT *************************************/

.profile-photo { display: block; max-width: 150px; margin: 0 auto 30px; border-radius: 100%; }

Nick Pettit
STAFF
Nick Pettit
Treehouse Teacher

Hi Warner,

Sorry for the slow reply! Unfortunately I'm not sure why this isn't working, but my guess is that it's not selecting the element properly. It could be because the CSS isn't being included properly (in which case nothing would be styled) or because the image doesn't have the class "profile-photo". A common mistake is to use an ID attribute when you really meant class, and vice versa.

Is the image actually circular in shape? If not, then this styling is not being applied. Another way to check if an element is being selected properly is to do something more dramatic that doesn't involve positioning, such as changing the background color, adding a border, or adding an outline. If those things don't appear, then you know that it's a selection problem of some kind.

You may also want to check this in other browsers. If you're using Firefox for example, there could be some issues that are detailed in the teacher notes.

Warner Cyr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Warner Cyr
Front End Web Development Techdegree Graduate 21,047 Points

The only browser that it shows correctly in is Google Chrome. I'll refer back to the Teachers notes to see why it may not be working in Firefox properly.

Thanks!

sumith panditha
sumith panditha
4,738 Points

i had the same problem & i used 'clear:both' on top of css class 'profile-photo' . now it works fine.