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

HTML How to Make a Website Styling Web Pages and Navigation Style the Image Captions

Sebastian Eguez
Sebastian Eguez
8,248 Points

Gallery alignment problem

Snapshot: https://w.trhou.se/g25ceger1t

/***********************************************
PAGE: PORTFOLIO
***********************************************/

#gallery {
    margin: 0;
    padding: 0;
    list-style: none;
}

#gallery li {
    float: left;
    width: 45%;
    margin: 2.5%;
    background-color: #f5f5f5;
    color: #bdc3c7;
}

#gallery li a {
    margin: 0;
    padding: 5%;
    font-size: 1em;
    color: #bdc3c7;
    text-align:center
}

Regarding #gallery li a

When I have the padding set to 5%, the images are misaligned with the gray background. The images shift to the right. Now, when I have the padding set to 0, it looks fine.

The tutorial has his set at 5% though. And it looks fine there.

2 Answers

Alex Watts
Alex Watts
8,396 Points

Hello Sebastian,

In the tutorial Nick sets the properties for the gallery to the paragraph tags nested inside it (see code below). You have to be careful when reviewing and writing code, so that you do not miss anything!

#gallery li a p {
    margin: 0;
    padding: 0%;
    font-size: 0.75em;
    color: #bdc3c7;
    text-align:center
}

P.S. Your gallery has collapsed. You will need to add a clear fix to this.

Good luck :) I like your website!

Sebastian Eguez
Sebastian Eguez
8,248 Points

ARE YOU KIDDING ME?!?!?!

I was trying so hard trying to make sure everything was the same. : (

Thank you!

Alex Watts
Alex Watts
8,396 Points

Thats alright. I have included the code you need to fix your gallery.

Add this to your css

.clearfix {
 content: " ";
 clear: both;
 display: table;
}
Add this class after your id

<ul id="gallery" class="clearfix">