简体   繁体   中英

HTML - Fancybox - Adding text below image thumbnail

I am using an HTML code for simple image gallery on my website from this demo: http://fancyapps.com/fancybox/demo/ Is there an easy way to add text below each thumbnail which would be different from the image title (which is displaying after clicking on a thumbnail)?

Thank you very much.

EDIT: Thanks for your help, but it was't quite what I asked. Anyway, my friend has solved it. Both image link and description must be included next to each other in one parent element, like this:

<div>
    <a ... ><img src="image link" alt="First picture" /></a>
    <p>Description</p>
</div>

Then the width of the div is set to the width of the image thumbnail, causing the description to "drop" down below the thumbnail.

Have you try using inline option? As it is quite similar to what you want.

Link Button

<a class="fancybox" href="#inline1" title="Lorem ipsum dolor sit amet">Inline</a>

Inline Html

<div id="inline1" style="width:400px;display: none;">
  <p>Your Main image could be here</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis mi eu elit tempor facilisis id et neque.</p>
</div>

You can wrap the text inside the <p> tag and add some CSS to fix the layout

<a class="fancybox" href="1_b.jpg" data-fancybox-group="gallery" title="Lorem ipsum dolor sit amet">
    <img src="1_s.jpg" alt="">
    <p>some text</p>
</a>

CSS:

.fancybox {
    display: inline-block;
    vertical-align: top;
}
.fancybox img {
    display: block;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM