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,238
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.

<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">
				<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">
				<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">
				<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">

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


4. To create a dynamic image gallery.

/* Dynamic Gallery */
$( '#gallery' ).click( function( e ) {
	$.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...