Lightbox
Bootstrap lightbox
Note: We are transitioning MDB4 to a legacy version and focusing on developing MDB5.
While we'll continue to support for the transition period, we encourage you to migrate to
MDB5. We're offering a huge discount on MDB5 PRO to help with your transition,
enabling you to leverage the full potential of the latest version. You can find more information here.
upgrade with discount
A Bootstrap lightbox is a group of images combined in one responsive gallery. Elements are grouped in a thumbnail grid, which can be displayed as a slideshow.
Basic example
A basic example of a lightbox with the most common use case with the bootstrap grid.
Example code:
<div class="row">
<div class="col-md-12">
<div id="mdb-lightbox-ui"></div>
<div class="mdb-lightbox no-margin">
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(117).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(117).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(98).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(98).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(131).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(131).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(123).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(123).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(118).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(118).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(128).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(128).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(132).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(132).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(115).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(115).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(133).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(133).webp" class="img-fluid" />
</a>
</figure>
</div>
</div>
</div>
// MDB Lightbox Init
$(function () {
$("#mdb-lightbox-ui").load("mdb-addons/mdb-lightbox-ui.html");
});
Initialization required
To use our Lightbox you have to initialize it in your project with the code below.
Initialization code:
// MDB Lightbox Init
$(function () {
$("#mdb-lightbox-ui").load("mdb-addons/mdb-lightbox-ui.html");
});
Predefined image size
A MDB LightBox uses the same image in two different sizes: thumbnail and large.
Such an approach let you increase the performance of your website.
<figure class="col-md-4">
<!--Large image-->
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(114).webp" data-size="1600x1067">
<!-- Thumbnail-->
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(114).webp" class="img-fluid">
</a>
</figure>
// MDB Lightbox Init
$(function () {
$("#mdb-lightbox-ui").load("mdb-addons/mdb-lightbox-ui.html");
});
Important:
1. The data-size
attribute should equal the size of the Large Image
2. The Thumbnail and Large images should have the same ratio
3. The Thumbnail should be 544px wide
4. The Large image shouldn't be wider than 1800px
<div class="row">
<div class="col-md-12">
<div id="mdb-lightbox-ui"></div>
<div class="mdb-lightbox no-margin">
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(117).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(117).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(98).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(98).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(131).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(131).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(123).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(123).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(118).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(118).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(128).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(128).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(132).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(132).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(115).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(115).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(133).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(133).webp" class="img-fluid" />
</a>
</figure>
</div>
</div>
</div>
// MDB Lightbox Init
$(function () {
$("#mdb-lightbox-ui").load("mdb-addons/mdb-lightbox-ui.html");
});
Gallery with margins
Remove the .no-margin
class to add margins to your images.
<div class="row">
<div class="col-md-12">
<div id="mdb-lightbox-ui"></div>
<div class="mdb-lightbox">
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(145).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(145).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(150).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(150).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(152).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(152).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(42).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(42).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(151).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(151).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(40).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(40).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(148).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(148).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(147).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(147).webp" class="img-fluid" />
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(149).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(149).webp" class="img-fluid" />
</a>
</figure>
</div>
</div>
</div>
// MDB Lightbox Init
$(function () {
$("#mdb-lightbox-ui").load("mdb-addons/mdb-lightbox-ui.html");
});
Gallery with heading
My Projects
<h2 class="font-weight-bold my-5 text-center">My Projects</h2>
<!--First row-->
<div class="row">
<!--First column-->
<div class="col-md-12">
<div id="mdb-lightbox-ui"></div>
<!--Full width lightbox-->
<div class="mdb-lightbox">
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Mockups/Lightbox/Thumbnail/img%20(63).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Mockups/Lightbox/Thumbnail/img%20(63).webp" class="img-fluid z-depth-1">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Mockups/Lightbox/Original/img%20(66).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Mockups/Lightbox/Thumbnail/img%20(66).webp" class="img-fluid z-depth-1">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Mockups/Lightbox/Original/img%20(65).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Mockups/Lightbox/Thumbnail/img%20(65).webp" class="img-fluid z-depth-1">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Mockups/Lightbox/Original/img%20(67).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Mockups/Lightbox/Thumbnail/img%20(67).webp" class="img-fluid z-depth-1">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Mockups/Lightbox/Original/img%20(68).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Mockups/Lightbox/Thumbnail/img%20(68).webp" class="img-fluid z-depth-1">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Mockups/Lightbox/Original/img%20(64).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Mockups/Lightbox/Thumbnail/img%20(64).webp" class="img-fluid z-depth-1">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Mockups/Lightbox/Original/img%20(69).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Mockups/Lightbox/Thumbnail/img%20(69).webp" class="img-fluid z-depth-1">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Mockups/Lightbox/Original/img%20(59).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Mockups/Lightbox/Thumbnail/img%20(59).webp" class="img-fluid z-depth-1">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Mockups/Lightbox/Original/img%20(70).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Mockups/Lightbox/Thumbnail/img%20(70).webp" class="img-fluid z-depth-1">
</a>
</figure>
</div>
<!--/Full width lightbox-->
</div>
<!--/First column-->
</div>
<!--First row-->
// MDB Lightbox Init
$(function () {
$("#mdb-lightbox-ui").load("mdb-addons/mdb-lightbox-ui.html");
});
Projects presentation
My projects
All about my work
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit, error amet numquam iure provident voluptate esse quasi, veritatis totam voluptas nostrum quisquam eum porro a pariatur accusamus veniam. At ab ea a molestiae corrupti numquam quo beatae minima ratione magni accusantium repellat eveniet quia vitae.
<h2 class="h1 text-center text-uppercase font-weight-bold mt-5 mb-3 mt-5">My projects</h2>
<!--Section description-->
<p class="text-center text-uppercase font-weight-bold">All about my work</p>
<!--Section description-->
<p class="section-description mt-5 pt-2">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit, error
amet numquam iure provident voluptate esse quasi, veritatis totam voluptas nostrum quisquam eum porro a
pariatur accusamus veniam. At ab ea a molestiae corrupti numquam quo beatae minima ratione magni accusantium
repellat eveniet quia vitae.</p>
<!--First row-->
<div class="row ml-3 mr-3 pb-4 pt-1">
<!--First column-->
<div class="col-md-12">
<div id="mdb-lightbox-ui"></div>
<!--Full width lightbox-->
<div class="mdb-lightbox">
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(135).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(135).webp" class="img-fluid z-depth-1">
</a>
<p class="text-uppercase font-weight-bold blue-grey-text mt-4">| Lorem ipsum dolor sit amet</p>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(128).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(128).webp" class="img-fluid z-depth-1">
</a>
<p class="text-uppercase font-weight-bold blue-grey-text mt-4">| Lorem ipsum dolor sit amet</p>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(133).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(133).webp" class="img-fluid z-depth-1">
</a>
<p class="text-uppercase font-weight-bold blue-grey-text mt-4">| Lorem ipsum dolor sit amet</p>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(131).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(131).webp" class="img-fluid z-depth-1">
</a>
<p class="text-uppercase font-weight-bold blue-grey-text mt-4">| Lorem ipsum dolor sit amet</p>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(130).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(130).webp" class="img-fluid z-depth-1">
</a>
<p class="text-uppercase font-weight-bold blue-grey-text mt-4">| Lorem ipsum dolor sit amet</p>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(132).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(132).webp" class="img-fluid z-depth-1">
</a>
<p class="text-uppercase font-weight-bold blue-grey-text mt-4">| Lorem ipsum dolor sit amet</p>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(134).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(134).webp" class="img-fluid z-depth-1">
</a>
<p class="text-uppercase font-weight-bold blue-grey-text mt-4">| Lorem ipsum dolor sit amet</p>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(1).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(1).webp" class="img-fluid z-depth-1">
</a>
<p class="text-uppercase font-weight-bold blue-grey-text mt-4">| Lorem ipsum dolor sit amet</p>
</figure>
</div>
<!--/Full width lightbox-->
</div>
<!--/First column-->
<div class="col-md-12 text-center py-4">
<a class="btn btn-outline-black waves-effect"><strong>more</strong></a>
</div>
</div>
<!--/First row-->
// MDB Lightbox Init
$(function () {
$("#mdb-lightbox-ui").load("mdb-addons/mdb-lightbox-ui.html");
});
Gallery with mixed content
<!--First row-->
<div class="row">
<!--First column-->
<div class="col-md-12">
<div id="mdb-lightbox-ui"></div>
<!--Full width lightbox-->
<div class="mdb-lightbox">
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(58).webp" data-size="781x1172">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(58).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(61).webp" data-size="781x1172">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(61).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(62).webp" data-size="781x1172">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(62).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(60).webp" data-size="781x1172">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(60).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(66).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(66).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(70).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(70).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-4">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(74).webp" data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(74).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(64).webp" data-size="781x1172">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(64).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(77).webp" data-size="781x1172">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(77).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(78).webp" data-size="781x1172">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(78).webp" class="img-fluid">
</a>
</figure>
<figure class="col-md-3">
<a href="https://mdbootstrap.com/img/Photos/Lightbox/Original/img%20(76).webp" data-size="781x1172">
<img src="https://mdbootstrap.com/img/Photos/Lightbox/Thumbnail/img%20(76).webp" class="img-fluid">
</a>
</figure>
</div>
<!--/Full width lightbox-->
</div>
<!--/First column-->
</div>
<!--/First row-->
// MDB Lightbox Init
$(function () {
$("#mdb-lightbox-ui").load("mdb-addons/mdb-lightbox-ui.html");
});