
How to create Product Image Gallery with Thumbnails
Before We Start
A gallery is one of the main components of a website, It contains links to the other sections and a user interface element within a website. The most important one and the first section that the user sees when he/she enters a website.
Product Image Gallery with Thumbnails CSS/html. So if you are a person who wishes to develop a website, you have to know how to create a gallery properly.
Product Image Gallery with Thumbnails CSS/html.? We are here to solve your problem. In this article we discuss how to create a gallery. Before we start please read the below articles which easier you to understand the process, if you are new to development.
Step 1 – Add HTML
It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag.
<body>
<div class="wrapper">
<header>
<h1>Product Image Gallery with Thumbnails</h1>
<p>Click on the thumbnail to view it larger on the right!</p>
</header>
<div class="image-gallery">
<aside class="thumbnails">
<a href="#" class="selected thumbnail" data-big="http://placekitten.com/420/600">
<div class="thumbnail-image" style="background-image: url(http://placekitten.com/420/600)"></div>
</a>
<a href="#" class="thumbnail" data-big="http://placekitten.com/450/600">
<div class="thumbnail-image" style="background-image: url(http://placekitten.com/450/600)"></div>
</a>
<a href="#" class="thumbnail" data-big="http://placekitten.com/460/700">
<div class="thumbnail-image" style="background-image: url(http://placekitten.com/460/700)"></div>
</a>
</aside>
<main class="primary" style="background-image: url('http://placekitten.com/420/600');"></main>
</div>
</div>
</body>
Step 2 – Add CSS
Copy and paste below code in your HTML editor between <style></style> tag.
<style>
.wrapper {
margin: 0 auto;
width: 80%;
text-align: center;
}
.image-gallery {
margin: 0 auto;
display: table;
}
.primary,
.thumbnails {
display: table-cell;
}
.thumbnails {
width: 300px;
}
.primary {
width: 600px;
height: 400px;
background-color: #cccccc;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.thumbnail:hover .thumbnail-image, .selected .thumbnail-image {
border: 4px solid #FFF;
}
.thumbnail-image {
width: 100px;
height: 100px;
margin: 20px auto;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
border: 4px solid transparent;
}
h1{
color: #FFF;
}
p{
color: #FFF;
}
</style>
Step 2 – Add JavaScript
We use some external JavaScript link to this code. No need to worry about this, copy and paste below code between <head></head> tag.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
Copy and paste below code in your HTML editor between <script></script> tag.
<script>
$(".thumbnail").on("click", function () {
var clicked = $(this);
var newSelection = clicked.data("big");
var $img = $(".primary").css("background-image", "url(" + newSelection + ")");
clicked.parent().find(".thumbnail").removeClass("selected");
clicked.addClass("selected");
$(".primary").empty().append($img.hide().fadeIn("slow"));
});
</script>
At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want.Enjoy it.

Video Tutorial
Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.
Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.