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

Question about text moving floating elements.

#galleryArea {
    display: block;
}

#gallery {
    list-style:none;
}

#gallery img {
    width: 100%;
    height: auto;
    max-width: 225px;
    max-height: 225px;
}

#gallery li {
    float: left;
    width: 33%;
    padding: 0 1.6%;
    text-align: center;
}

#gallery a {
    color: black;
}
<div id="galleryArea">
        <ul id="gallery">
            <li><a href="#">
                <img src="img/img.png" />
                <p>Desc...</p>
            </a></li>
            <li><a href="#">
                <img src="img/img.png" />
                <p>Desc...</p>
            </a></li>
            <li><a href="#">
                <img src="img/img.png" />
                <p>Desc...</p>
            </a></li>
            <li><a href="#">
                <img src="img/img.png" />
                <p>Desc...</p>
            </a></li>
            <li><a href="#">
                <img src="img/img.png" />
                <p>Desc...</p>
            </a></li>
            <li><a href="#">
                <img src="img/img.png" />
                <p>Desc...</p>
            </a></li>
        </ul>
    </div>

I am trying to add multi-line descriptions to each of these images but whenever I do the image below is pushed down a very large amount. I have found out, through trial and error, that it is because of the float: left; in the #gallery li selector.

However, I need all of the gallery elements to stay arranged like that so I need another fix.

Thanks to anyone who helps!

1 Answer

Hi Luke,

Have you considered flexbox?

Craig