Lightweight Customizable Lightbox Plugin - ColorBox

File Size: 0.99 MB
Views Total: 30358
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Lightweight Customizable Lightbox Plugin - ColorBox

ColorBox is a Lightweight Customizable Lightbox Plugin built with jQuery that allows you to display elements with the lightbox effect on the page. It supports photos, grouping, slideshow, ajax, inline, and iframed content.

Basic Usage:

1. Include jQuery library and ColorBox.js on your web page

<script src=""></script>
<script src="../jquery.colorbox.js"></script>

2. Include jQuery ColorBox CSS

<link rel="stylesheet" href="colorbox.css" />

3. Call the plugin with options. Assign the ColorBox event to elements

    $(".group2").colorbox({rel:'group2', transition:"fade"});

4. Markup

<p><a class="group2" href="1.jpg" title="">Grouped Photo 1</a></p>
<p><a class="group2" href="2.jpg" title="">Grouped Photo 2</a></p>
<p><a class="group2" href="3.jpg" title="">Grouped Photo 3</a></p>

5. Default settings object.

// data sources
html: false,
photo: false,
iframe: false,
inline: false,

// behavior and appearance
transition: "elastic",
speed: 300,
fadeOut: 300,
width: false,
initialWidth: "600",
innerWidth: false,
maxWidth: false,
height: false,
initialHeight: "450",
innerHeight: false,
maxHeight: false,
scalePhotos: true,
scrolling: true,
opacity: 0.9,
preloading: true,
className: false,
overlayClose: true,
escKey: true,
arrowKey: true,
top: false,
bottom: false,
left: false,
right: false,
fixed: false,
data: undefined,
closeButton: true,
fastIframe: true,
open: false,
reposition: true,
loop: true,
slideshow: false,
slideshowAuto: true,
slideshowSpeed: 2500,
slideshowStart: "start slideshow",
slideshowStop: "stop slideshow",
photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i,

// alternate image paths for high-res displays
retinaImage: false,
retinaUrl: false,
retinaSuffix: '@2x.$1',

// internationalization
current: "image {current} of {total}",
previous: "previous",
next: "next",
close: "close",
xhrError: "This content failed to load.",
imgError: "This image failed to load.",

// accessbility
returnFocus: true,
trapFocus: true,

// callbacks
onOpen: false,
onLoad: false,
onComplete: false,
onCleanup: false,
onClosed: false,

More Examples:

Change Logs:


  • Fixed bug where using the inline property would duplicate target elements, if the selector matched multiple elements.


  • Fixed regression that caused error in IE8 when the calculated initial size was negative.


  • Fixed iframe attribute name (allowFullScreen to allowFullscreen).


  • Replaced the inline onclick handler for cboxPhoto with a namespaced event for easier unbinding. 


  • Adding to NPM, merged white-space cleanup & new language file.


  • Adding to NPM, merged white-space cleanup & new language file.


  • When opening, append Colorbox to the DOM if it was detached for whatever reason.


  • Fixed regression introduced with v1.5.12 with legacy versions of jQuery (1.3x-1.6x).


  • Allowed setting the overlay opacity via CSS, by setting Colorbox's opacity property to false. 
  • Fixed bug where setting opacity to 0 was ignored. 


  • Minor misc. tweaks


  • Fixed inline content bug when using child selectors.


  • Fixed accidental leak of global variable.


  • Fix potential error when calling Colorbox directly. References #591
  • Potentially worked around browser limitation of reporting that an image height and width is 0 immediately after onload.
  • by HazZbroGaminG


  • Applied maxWidth and maxHeight to the initialWidth and initialHeight


  • Allow setting the overlay opacity through CSS, rather than having to use Colorbox's opacity property.


  • Fixed potential issue where IE9+ wouldn't close the modal when clicking on the overlay.
  • Added access to settings object in callbacks.


  • Added svg to image types regex


  • Fixed regression that broke direct calls to Colorbox, ie. $.colorbox(…)
  • removed any default margin and padding from Colorbox's iframe.


  • Changed when the className is applied: immediately on open, but only updated immediately prior to transition.
  • Fixed potential style flash if #cboxLoadedContent is given a background. 
  • Misc. code cleanup


  • Fixed potential error when resizing


  • version update.


  • Fixed an issue where private events propagated to the document in versions of jQuery prior to 1.7.
  • Fixed a bug where events are propagated to document from $events.


  • Updated stylesheets to avoid issue with using `div {max-width:100%}


  • Added longdesc and aria-describedby attributes to photos. 
  • Used setAttribute to set londesc, so that the value is accessible via DOM Node longDesc property


  • add Hebrew translation
  • fixed a slideshow regression from 1.4.27


  • Fixed a potential issue with using the open property with mixed slideshow and non-slideshow groups


  • Fixed a width calculation issue relating to using margin:auto on #cboxLoadedContent.


  • Fixed a regression in IE7 and IE8 that was causing an error.


  • Use an animation speed of zero between same-sized content (fixed).


  • Added closeButton option. Set to false to remove the close button.


  • Bugfix loading overlay/graphic append order


This awesome jQuery plugin is developed by jackmoore. For more Advanced Usages, please check the demo page or visit the official website.