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

Image nested in figure alignment issue

Hi! I'm trying to make my own flexible site with picture nested in figure element. For some reason, I'm unable to center align img inside the figure box. It is close to the left side. I've try to use figure { text-align: center;} but with no success. Also, I've try to set: img { margin: auto;} But again, no result. Any ideas how I can solve it? TIA

do you have your code so i can look into it better for you?

1 Answer

A R
A R
12,834 Points

You might also want to look into setting the margin more specifically.

Open up your dev tools, double click on your CSS styling and type in some changes you want to make. Playing around with things like this can save you from having to change your code a million times.

You mention having a flexible site - are you using flexbox? If you're not already it might help, since it has a lot of powerful tools for aligning content blocks.