Bootstrap Thumbnails
This chapter explains Bootstrap thumbnails. Most sites need to lay out images, videos, text, etc. in a grid. Bootstrap provides an easy way to do this with thumbnails. The steps to create a thumbnail with Bootstrap are as follows:
- Add an element with class around the image .thumbnail 's tag.
- This adds four pixels of padding and a gray border.
- When the mouse hovers over the image, an outline of the image is animated in.
The following example demonstrates the default thumbnail:
Example
<div class="row">
<div class=">col-sm-6 col-md-3
"
<a href="" class="thumbnail">
<img src="/wp-content/uploads/2014/06/kittens.jpg" alt=">Generic placeholder thumbnail
"
a
div
<div class=">col-sm-6 col-md-3
"
<a href="" class="thumbnail">
<img src="/wp-content/uploads/2014/06/kittens.jpg" alt=">Generic placeholder thumbnail
"
a
div
<div class=">col-sm-6 col-md-3
"
<a href="" class="thumbnail">
<img src="/wp-content/uploads/2014/06/kittens.jpg" alt=">Generic placeholder thumbnail
"
a
div
<div class=">col-sm-6 col-md-3
"
<a href="" class="thumbnail">
<img src="/wp-content/uploads/2014/06/kittens.jpg" alt=">Generic placeholder thumbnail
"
a
div
div
Try it »
The result is as follows:
Adding custom content
Now that we have a basic thumbnail, we can add various HTML content to it, such as headings, paragraphs, or buttons. The specific steps are as follows:
- Change the element with class .thumbnail 's tag to
。
- Inside that
, you can add anything you want. Since this is a, we can use the default span-based naming convention to adjust the size.
- If you want to group multiple images, place them in an unordered list and float each list item to the left.
The following example demonstrates this:
Example
<div class="row">
<div class=">col-sm-6 col-md-3
"
<div class="thumbnail">
<img src="/wp-content/uploads/2014/06/kittens.jpg" alt=">Generic placeholder thumbnail
"
<div class="caption">
<h3>Thumbnail label
h3
<
p
Some example text. Some example text.
p
<p>
<a href="" class=">btn btn-primary
"
role
=
"
button
"
button
a
<a href="" class=">btn btn-default
"
role
=
"
button
"
button
a
p
div
div
div
<div class=">col-sm-6 col-md-3
"
<div class="thumbnail">
<img src="/wp-content/uploads/2014/06/kittens.jpg" alt=">Generic placeholder thumbnail
"
<div class="caption">
<h3>Thumbnail label
h3
<
p
Some example text. Some example text.
p
<p>
<a href="" class=">btn btn-primary
"
role
=
"
button
"
button
a
<a href="" class=">btn btn-default
"
role
=
"
button
"
button
a
p
div
div
div
<div class=">col-sm-6 col-md-3
"
<div class="thumbnail">
<img src="/wp-content/uploads/2014/06/kittens.jpg" alt=">Generic placeholder thumbnail
"
<div class="caption">
<h3>Thumbnail label
h3
<
p
Some example text. Some example text.
p
<p>
<a href="" class=">btn btn-primary
"
role
=
"
button
"
button
a
<a href="" class=">btn btn-default
"
role
=
"
button
"
button
a
p
div
div
div
<div class=">col-sm-6 col-md-3
"
<div class="thumbnail">
<img src="/wp-content/uploads/2014/06/kittens.jpg" alt=">Generic placeholder thumbnail
"
<div class="caption">
<h3>Thumbnail label
h3
<
p
Some example text. Some example text.
p
<p>
<a href="" class=">btn btn-primary
"
role
=
"
button
"
button
a
<a href="" class=">btn btn-default
"
role
=
"
button
"
button
a
p
div
div
div
div
Try it »
The result is as follows: