Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't figure out how to use Bootstrap thumbnail component

I'm trying to use Bootstrap's thumbnail component to display a list of product categories with thumbnail images. I want users to click the thumbnails to go to the category.

The documentation on the Bootstrap website provides this basic markup:

<ul class="thumbnails">
    <li class="span4"> 
        <a href="#" class="thumbnail">
            <img data-src="holder.js/300x200" alt="">
        </a>
    </li>
    ...
</ul>

I've Googled for information about holder.js, found the official holder.js page, downloaded the zip version, put the files in my site's js folder and linked to the holder.js file with a script tag in my HTML.

But how/where in the markup do I specify what image files to use?

I also need to include a category name under each image, probably with a span or h4 tag. This would need to form part of the clickable block.

UPDATE: Just to clarify, it's really only the styling aspects of the thumbnail component that I want to utilise. So perhaps I can achieve this with the thumbnails component and associated HTML markup, and leave out holder.js altogether?

This is the kind of HTML mark-up I would like to use:

<ul class="thumbnails">
    <li class="span4">
        <a href="/category-name/" class="thumbnail">
            <img src="/assets/images/filename.jpg" alt="">
            <span>Category name</span>
        </a>
    </li>
    ...
</ul>
like image 769
JonB Avatar asked Apr 15 '13 14:04

JonB


People also ask

How do I create a thumbnail image in Bootstrap?

Image Thumbnails: In Bootstrap 4, the image thumbnail is a border surrounded by the image. To create this image thumbnail you can use the . img-thumbnail class.

What is a thumbnail according to Bootstrap?

Thumbnail Image: A thumbnail is a small image that represents a larger image. Bootstrap has an easy way to do this with thumbnails. Bootstrap's . thumbnail class is used to show linked images in grids (grid system), a thumbnail is created using class .

Which class makes thumbnail image in Bootstrap?

To add a thumbnail to the image, use the . img-thumbnail Bootstrap class.


1 Answers

Holder.js is just image placeholder framework based on javascript and inline images. It is used by bootstrap to create sample images. There is no need in this library on production. So instead of using data-src attribute and holder.js library you should use src attribute and markup like:

<ul class="thumbnails">
    <li class="span4">
        <a class="thumbnail" href="#">
            <img src="/image/path.jpg" alt="My Image" />                
            <span class="caption">This is my image</span>
        </a>
    </li>
</ul>

You can also need to disable text underline in image caption. Just use css:

a.thumbnail:hover {
    text-decoration: none;
}

Example: http://jsfiddle.net/M3fpA/46/

like image 169
sody Avatar answered Nov 07 '22 21:11

sody