Hey guys, today in this post we are going to learn about Create a Custom Image Gallery With a Horizontal Thumbnail Carousel Simply using Custom JQuery Small Function and CSS for Create Image Gallery.
Files we used in this post example:-
imageGallerySlider.html | HTML File | It is used for Create a Custom Image Gallery With a Horizontal Thumbnail Carousel. |
imageGalleryFunction.js |
JavaScript File | It is holding JavaScript click functionality for Show/Hide and Rotate the Image Gallery Slider. |
imageGalleryStyle.css |
Style CSS File | It is used for Image Gallery Slider Alignment. |
jquery-1.7.1.min.js |
JQuery Library Min File | It is a JQuey Library that is provided by JQuery. |
Final Output
You can download file directly from github by Click Here.
Other related post that would you like to learn in Salesforce
Download Supported jQuery Library for Custom Banner Rotating Image with Text Slider.
Step 1:- Create HTML File : imageGallerySlider.html
imageGallerySlider.html [HTML File]
![]() |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://w3web.net/wp-includes/js/jquery-1.7.1.min.js"></script>
<link href="include/imageGalleryStyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="include/imageGalleryFunction.js"></script>
</head>
<body>
<div class="galeryMain">
<div class="glrlyImgZoom">
<div class="zoomItem" id="0"><img src="https://www.w3web.net/wp-content/uploads/2020/10/lwc-lookupContactFiture.png" width="500" height="335" alt="" /></div>
<div class="zoomItem" id="1"><img src="https://www.w3web.net/wp-content/uploads/2020/10/bannerRotateSlideFeature.png" width="500" height="335" alt="" /></div>
<div class="zoomItem" id="2"><img src="https://www.w3web.net/wp-content/uploads/2020/09/lwcSearchAccount.png" width="500" height="335" alt="" /></div>
<div class="zoomItem" id="3"><img src="https://www.w3web.net/wp-content/uploads/2020/09/lwcModalPopupFeature.png" width="500" height="335" alt="" /></div>
<div class="zoomItem" id="4"><img src="https://www.w3web.net/wp-content/uploads/2020/09/insertContactFeatute-lwc.png" width="500" height="335" alt="" /></div>
<div class="zoomItem" id="5"><img src="https://www.w3web.net/wp-content/uploads/2020/09/insertAccountLwc.png" width="500" height="335" alt="" /></div>
<div class="zoomItem" id="6"><img src="https://www.w3web.net/wp-content/uploads/2020/09/avoidDuplicateWithApex.png" width="500" height="335" alt="" /></div>
<div class="zoomItem" id="7"><img src="https://www.w3web.net/wp-content/uploads/2020/09/lastModifiedDate.png" width="500" height="335" alt="" /></div>
<div class="zoomItem" id="8"><img src="https://www.w3web.net/wp-content/uploads/2020/09/pillFeatureImg.png" width="500" height="335" alt="" /></div>
<div class="zoomItem" id="9"><img src="https://www.w3web.net/wp-content/uploads/2020/09/eventApplicationLightning.png" width="500" height="335" alt="" /></div>
</div>
<div class="thumbImgMain">
<div class="autoHide">
<span class="pre"><a href="#"><img src="images/lft-arrow.gif" width="10" height="35" alt="" /></a></span>
<ul class="thumbList">
<li><a href="#"><img src="https://www.w3web.net/wp-content/uploads/2020/10/lwc-lookupContactFiture.png" width="75" height="50" alt="" /></a></li>
<li><a href="#"><img src="https://www.w3web.net/wp-content/uploads/2020/10/bannerRotateSlideFeature.png" width="75" height="50" alt="" /></a></li>
<li><a href="#"><img src="https://www.w3web.net/wp-content/uploads/2020/09/lwcSearchAccount.png" width="75" height="50" alt="" /></a></li>
<li><a href="#"><img src="https://www.w3web.net/wp-content/uploads/2020/09/lwcModalPopupFeature.png" width="75" height="50" alt="" /></a></li>
<li><a href="#"><img src="https://www.w3web.net/wp-content/uploads/2020/09/insertContactFeatute-lwc.png" width="75" height="50" alt="" /></a></li>
<li><a href="#"><img src="https://www.w3web.net/wp-content/uploads/2020/09/insertAccountLwc.png" width="75" height="50" alt="" /></a></li>
<li><a href="#"><img src="https://www.w3web.net/wp-content/uploads/2020/09/avoidDuplicateWithApex.png" width="75" height="50" alt="" /></a></li>
<li><a href="#"><img src="https://www.w3web.net/wp-content/uploads/2020/09/lastModifiedDate.png" width="75" height="50" alt="" /></a></li>
<li><a href="#"><img src="https://www.w3web.net/wp-content/uploads/2020/09/pillFeatureImg.png" width="75" height="50" alt="" /></a></li>
<li><a href="#"><img src="https://www.w3web.net/wp-content/uploads/2020/09/eventApplicationLightning.png" width="75" height="50" alt="" /></a></li>
</ul>
<span class="nxt"><a href="#"><img src="images/rt-arrow.gif" width="10" height="35" alt="" /></a></span>
</div>
</div>
</div>
<br/>
<!--Start RelatedTopics Section-->
<div style="border:1px #ddd solid; padding:10px; background:#eee; margin:40px 0;">
<p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/05/thumbsUpLike.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:16px; font-style:italic; display:inline-block; margin-right:5px;">Don't forget to check out:-</span><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer" style="text-decoration:none;" data-aura-rendered-by="440:0">An easy way to learn step-by-step online free Salesforce tutorial, To know more Click <span style="color:#ff8000; font-size:18px;" data-aura-rendered-by="442:0">Here..</span></a></strong></p>
<br/><br/>
<p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/07/tickMarkIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:17px; font-style:italic; display:inline-block; margin-right:5px; color:rgb(255 128 0);">You May Also Like โ</span> </strong></p>
<div style="display:block; overflow:hidden;">
<div style="width: 50%; float:left; display:inline-block">
<ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;">
<li><a href="https://www.w3web.net/lwc-get-set-lightning-checkbox-value/" target="_blank" rel="noopener noreferrer">How to get selected checkbox value in lwc</a></li>
<li><a href="https://www.w3web.net/display-account-related-contacts-in-lwc/" target="_blank" rel="noopener noreferrer">how to display account related contacts based on AccountId in lwc</a></li>
<li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to create lightning datatable row actions in lwc</a></li>
<li><a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer">how to use if and else condition in lwc</a></li>
<li><a href="https://www.w3web.net/get-selected-radio-button-value-and-checked-default-in-lwc/" target="_blank" rel="noopener noreferrer">how to display selected radio button value in lwc</a></li>
</ul>
</div>
<div style="width: 50%; float:left; display:inline-block">
<ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;">
<li><a href="https://www.w3web.net/display-account-related-contacts-lwc/" target="_blank" rel="noopener noreferrer">display account related contacts based on account name in lwc</a></li>
<li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to insert a record of account Using apex class in LWC</a></li>
<li><a href="https://www.w3web.net/fetch-picklist-values-dynamic-in-lwc/" target="_blank" rel="noopener noreferrer">how to get picklist values dynamically in lwc</a></li>
<li><a href="https://www.w3web.net/edit-save-and-remove-rows-dynamically-in-lightning-component/" target="_blank" rel="noopener noreferrer">how to edit/save row dynamically in lightning component</a></li>
<li><a href="https://www.w3web.net/update-parent-object-from-child/" target="_blank" rel="noopener noreferrer">update parent field from child using apex trigger</a></li>
</ul>
</div>
<div style="clear:both;"></div>
<br/>
<div class="youtubeIcon">
<a href="https://www.youtube.com/channel/UCW62gTen2zniILj9xE6LmOg" target="_blank" rel="noopener noreferrer"><img src="https://www.w3web.net/wp-content/uploads/2021/11/youtubeIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;"/> <strong>TechW3web:-</strong> To know more, Use this <span style="color: #ff8000; font-weight: bold;">Link</span> </a>
</div>
</div>
</div>
<!--End RelatedTopics Section-->
</body>
</html>
Step 2:- Create JavaScript File : imageGalleryFunction.js
imageGalleryFunction.js [JavaScript File]
![]() |
$(document).ready(function(){
$('.galeryMain').glerySlide();
})
$.fn.glerySlide = function()
{
var thisObj = $(this);
var ul = thisObj.find('ul:first');
var size = thisObj.find('li').size();
var liwidth = thisObj.find('li').outerWidth(true);
ul.width(size*liwidth);
thisObj.find('li:first').find('a:first').addClass('active');
var animation = true;
var backSize = '-' + liwidth*6 + 'px';
$('.nxt a').click(function(){
var x1 = $("ul.thumbList li a:eq("+i+")")
if(!$(this).is('.active'))
{
if(animation)
{
$('ul.thumbList').animate({left:'-=' + liwidth+'px'}, 100, function(){
autoPlay();
});
}
}
return false;
})
$('.pre a').click(function(){
if(!$(this).is('.active'))
{
if(animation)
{
$('ul.thumbList').animate({left:'+=' + liwidth+'px'}, 100, function(){
autoPlay();
})
}
}
return false;
})
function autoPlay()
{
animation = true;
if($(ul).css('left')=='0px')
{
$('.nxt a').removeClass('active');
$('.pre a').addClass('active');
}
else if($(ul).css('left')==('-' + liwidth*(size-6) + 'px'))
{
$('.pre a').removeClass('active');
$('.nxt a').addClass('active');
}
else
{
$('.nxt a').removeClass('active');
$('.pre a').removeClass('active');
}
}
$('ul.thumbList li a').each(function(i){
$(this).attr('rel', i);
})
$('.pre a').addClass('active');
$('.zoomItem').not(':first').hide();
$('ul.thumbList li a').click(function(){
$('.zoomItem').hide();
$('#' + this.rel).show();
$('ul.thumbList li a').removeClass('active');
$(this).addClass('active');
})
var i=0;
function autoPlaySlide()
{
i++;
if($('zoomItem:last').css('display')=='block')
{
i=0;
}
else if(i > 5)
{
$('ul.thumbList').animate({left:backSize}, 100);
}
if($('.zoomItem:last').css('display')=='block')
{
$('ul.thumbList').animate({left: '0'}, 100);
i=0;
}
$('.pre a').removeClass('active');
$("ul.thumbList li a").removeClass('active');
$("ul.thumbList li a:eq("+i+")").addClass('active');
$('.zoomItem').fadeOut();
$('#' + i).fadeIn();
}
var setTimespan = setInterval(function(){autoPlaySlide()}, 3000);
$('.pre a, .nxt a, ul.thumbList li a img').hover(function(){
clearInterval(setTimespan);
}, function(){
setTimespan = setInterval(function(){autoPlaySlide()}, 3000);
})
}
// JavaScript Document
Step 3:- Create Style CSS : imageGalleryStyle.css
imageGalleryStyle.css [Style CSS File]
![]() |
.galeryMain{ width:500px; margin:auto;}
.glrlyImgZoom{ width:500px; height:335px; border:2px #666 solid; margin-bottom:10px; position:relative;}
.zoomItem{ position:absolute; left:0; top:0;}
.thumbImgMain{ position:relative;}
.autoHide{ width:500px; overflow:hidden;}
ul.thumbList{ margin:0; padding:0; list-style:none; position:relative;}
ul.thumbList li{ width:75px; float:left; margin-right:9px;}
ul.thumbList li a img{ border:2px #666 solid;}
ul.thumbList li a:hover img, ul.thumbList li a.active img{ border:2px #ff0000 solid;}
.pre{ width:10px; position:absolute; left:-20px; top:10px;}
.pre a.active img{opacity:0.5;}
.nxt{ width:10px; position:absolute; right:-20px; top:10px;}
.nxt a.active img{opacity:0.5;}
Further post that would you like to learn in Salesforce
What is jQuery image slider?
The jQuery image slider contains images that run them using the previous and next icons.
How do I connect JavaScript to HTML?
o include an external JavaScript file, we can use the script tag with the attribute src . You've already used the src attribute when using images. The value for the src attribute should be the path to your JavaScript file. This script tag should be included between the 'head' tags in your HTML document.
Where do I write JavaScript code?
JavaScript provides 3 places to put the JavaScript code: within body tag, within head tag and external JavaScript file.
Related Topics | You May Also Like
Our Free Courses โ
๐ Get Free Course โ
![]() ๐ Salesforce Administrators ๐ Salesforce Lightning Flow Builder ๐ Salesforce Record Trigger Flow Builder |
๐ Get Free Course โ
![]() ๐ Aura Lightning Framework ๐ Lightning Web Component (LWC) ๐ Rest APIs Integration |