jQuery Touch Enabled Responsive Image Lightbox

jQuery Touch Enabled Responsive Image Lightbox
Code Snippet:Swipebox
Author: Brutal Design
Published: January 19, 2024
Last Updated: January 22, 2024
Downloads: 4,367
License: MIT
Edit Code online: View on CodePen
Read More

The Swipebox is a cross-platform, cross browsers jQuery touch-enabled responsive image lightbox that supports swipe-to-slide images, video, and inline contents.

Main Features

  1. Touch enabled, supports swipe (left, right, top, down) to slide the images/video/inline content.
  2. Keyboard Navigation for desktop
  3. CSS transitions with jQuery fallback
  4. Retina support for UI icons
  5. Easy CSS customization
  6. Video, Images, and Inline content

How to Use Touch Enabled Responsive Image Lightbox:

1. Load the jQuery and Swipebox JavaScript and CSS files into HTML document.

<!--jQuery-->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>

<!--Swipebox JS-->
<script src="src/js/jquery.swipebox.js"></script>

<!--Swipebox CSS-->
<link rel="stylesheet" href="src/css/swipebox.css">

2. Create HTML structure for images like the below:

	
	<section id="exemple" class="container">
		<div class="wrap small-width">
			<div id="try"></div>
			<ul id="box-container">
				<li class="box">
					<a href="https://source.unsplash.com/600x300/?fitness" class="swipebox" title="Fitness">
						<img src="https://source.unsplash.com/600x300/?fitness" alt="image">
					</a>
				</li>
				<li class="box">
					<a href="https://source.unsplash.com/600x300/?yoga" class="swipebox" title="Yoga">
						<img src="https://source.unsplash.com/600x300/?yoga" alt="image">
					</a>
				</li>
				<li class="box">
					<a href="https://source.unsplash.com/600x300/?bikini" class="swipebox" title="Bikni">
						<img src="https://source.unsplash.com/600x300/?bikini" alt="www.codehim.com">
					</a>
				</li>
				<li class="box">
					<a href="https://source.unsplash.com/600x300/?girl" class="swipebox" title="Girl">
						<img src="https://source.unsplash.com/600x300/?girl" alt="www.codehim.com">
					</a>
				</li>
			</ul>
		</div>
	</section>

3. Call the plugin in the jQuery document ready function to activate the lightbox.

$(document).ready(function(){
$('.swipebox').swipebox();
});

4. To create a dynamic image gallery.

/* Dynamic Gallery */
$( '#gallery' ).click( function( e ) {
	e.preventDefault();
	$.swipebox( [
		{ href : 'your-image-addrss-here', title : 'My Caption' },
		{ href : 'your-image-addrss-here', title : 'My Second Caption' }
		   ] );

That’s all! hopefully, you have successfully created a responsive image lightbox using swipebox code snippet. If you have any questions or facing any issues, feel free to comment below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link

X