Tim Aich
Tim Aich

Reputation: 71

Putting text underneath images in a list (with jQuery lightbox)

Right now I've got a large list of images for use with the jQuery Lightbox plugin, simply formatted like:

<div id="gallery"><ul>
    <li><a href="photos/1.jpg"><img src="photos/1_t.jpg" width="72" height="72" alt="" /></a></li>
    <li><a href="photos/2.jpg"><img src="photos/2_t.jpg" width="72" height="72" alt="" /></a></li>
    <li><a href="photos/3.jpg"><img src="photos/3_t.jpg" width="72" height="72" alt="" /></a></li>
    <li><a href="photos/4.jpg"><img src="photos/4_t.jpg" width="72" height="72" alt="" /></a></li>
    <li><a href="photos/5.jpg"><img src="photos/5_t.jpg" width="72" height="72" alt="" /></a></li>
</ul></div>

CSS:

#gallery {
    background-color: #efefef;
    border:1px solid #ccc;
    background-size: 100%;
    width: 90%;
    margin-top:20px;
}

#gallery ul { list-style: none; }
#gallery ul li { 
    display: inline; margin-left: 5px; margin-right: 5px; 
    font-size:.4em;

}
#gallery ul img {
    border: 5px solid #3e3e3e;
    border-width: 2px 2px 2px;
}
#gallery ul a:hover img {
    border: 5px solid #fff;
    border-width: 2px 2px 2px;
    border-color: #8f8f8f;
    color: #fff;
}
#gallery ul a:hover { color: #fff; }

And what I'm trying to do is make it so there's caption text placed under each image. Ex:

<li><a href="photos/1.jpg">
        <img src="photos/1_t.jpg" width="72" height="72" alt="" /></a>
        Image 1
    </li>

But right now I'm just getting the caption showing up to the right of the image. I can't think of the best way about going about doing this. Any help would be much appreciated.

Upvotes: 1

Views: 527

Answers (2)

darshanags
darshanags

Reputation: 2519

Try;

HTML:

<li><a href="photos/1.jpg"><img src="photos/1_t.jpg" width="72" height="72" alt="" /></a><p>Image 1</p></li>

CSS:

#gallery ul li { 
   float:left; margin-left: 5px; margin-right: 5px; 
   font-size:.4em;

}

Upvotes: 2

Explosion Pills
Explosion Pills

Reputation: 191749

I addition to the <br> after the image for the caption, use display: inline-block for the <li> elements rather than just display: inline.

http://jsfiddle.net/nfEMs/1/

Upvotes: 1

Related Questions