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 can I center logo with css (mobile responsive version)?

Greetings Treehouse, I just finished the "How to Make a Website" section and wanted to practice so I'm doing the site from scratch again with some custom parts. I removed h1/h2 and replaced with an image. I cant seem to get the logo centered above the nav. I have tried floating, playing with margins and padding.

direct link: http://ramonliriano.com/project1/

I'm building mobile version first like in the course. Working on the tablet/desktop versions later.

Any advise will be greatly appreciated.

Thanx :)

2 Answers

You would need to set the image display to block and auto for the left and right margins.

.logo {
  display: block;
  margin: 0 auto;
}

Here is a great guide to help with centering: http://css-tricks.com/centering-css-complete-guide/

Thank you, was on right track was just missing display block.

I changed #logo to display block and then the margins to o and auto. Worked for me. This is what I had:

#logo {
    display:block;
    max-width: 300px;
    margin: 0 auto;
    width: 90%;
}

Ty Emma.