• This field is for validation purposes and should be left unchanged.

Gecko Designs
523 N Higgins Ave
Missoula, MT 59802

(406) 662-1123

Dreamweaver Tutorial: Add a jQuery Lightbox to Dreamweaver websites

Written by Gabriel on May 9, 2012

Learn How to Add a Lightbox to Adobe Dreamweaver CS5.5 Websites

In this tutorial, you will learn how to add the popular jQuery Lightbox function to a Dreamweaver webpage without using Code View.

What is the jQuery Lightbox?

In today’s internet, the slickest and most common method of displaying higher resolution images or featured images when a link to an image is clicked is to show a larger image overlaid above the entire webpage. The area surrounding the Lightbox image is typically grayed out to highlight the displayed image.

How does Lightbox look & function in a Dreamweaver website?

Below is an example to demonstrate the exact jQuery Lightbox that is constructed using this free Adobe Dreamweaver CS5.5 tutorial.

Step 1: Linking the Webpage with the jQuery Library

To begin, we must open an existing webpage or create a new one in Adobe Dreamweaver CS5.5. Once the page has been created and saved, download the jQuery library file and save it to a new folder within your project’s root folder called/js/. To link the Dreamweaver webpage to this new javascript file, click the cursor into the Head Content Panel then go to the Insert panel and choose Common > Scripts > Script. Click the folder button and browse to your jQuery file, press ‘OK’.


Step 2: Add Custom Javascript to the Adobe Dreamweaver Webpage

To add javascript to the webpage directly, again click the cursor into the Head Content Panel then choose Insert > Scripts > Script. Instead of browsing to a file, place the cursor into the Content text area of the Script Window and paste the javascript (code) below.

jQuery(document).ready(function($) {

	$('.lightbox_trigger').click(function(e) {

		//prevent default action (hyperlink)

		//Get clicked link href
		var image_href = $(this).attr("href");

		If the lightbox window HTML already exists in document, 
		change the img src to to match the href of whatever link was clicked

		If the lightbox window HTML doesn't exists, create it and insert it.
		(This will only happen the first time around)

		if ($('#lightbox').length > 0) { // #lightbox exists

			//place href as img src value
			$('#content_lightbox').html('<img src="' + image_href + '" />');

			//show lightbox window - you could use .show('fast') for a transition

		else { //#lightbox does not exist - create and insert (runs 1st time only)

			//create HTML markup for lightbox window
			var lightbox = 
			'<div id="lightbox">' +
				'<p>Click to close>/p>' +
				'<div id="content_lightbox">' + //insert clicked link's href into img src
					'<img src="' + image_href +'" />' +
				'</div>' +	

			//insert lightbox HTML into page


	//Click anywhere on the page to get rid of lightbox window
	$('#lightbox').live('click', function() { //must use live, as the lightbox element is inserted into the DOM

Step 3: Place Thumbnail Links into the Dreamweaver Webpage

To make this Lightbox work, there must be a hyperlink for each image that is to be displayed with Lightbox. Each of these links must have a class called lightbox_trigger or they will not open the images with Lightbox. To add a class that is not in your style sheet, highlight each link individually then press Shift + F5 to open the Tag Editor window for a. Select the Style Sheet/Accessibility tab and type the classlightbox_trigger into the Class text field as shown below.


Step 4: Create CSS Rules to Display the Lightbox on the Dreamweaver Webpage

Using the CSS Styles panel on the right side of the Adobe Dreamweaver CS5.5, create three new rules relating to the lightbox div. These rules are called #lightbox#lightbox p, and #lightbox img. These can be customized to your liking, below I have listed the rules I recommend.


  • position: fixed
  • top: 0
  • left: 0
  • width: 100%
  • height: 100%
  • background: [save this overlay 1×1 pixel png image into the appropriate images sub-folder of the Dreamweaver website, then browse to it and set it as the repeating background image]
  • text-align: center

#lightbox p

  • text-align: right
  • color: #FFFFFF [white]
  • margin-right: 20px
  • font-size: 12px

#lightbox img

  • max-width: 940px [this will ensure that very wide images are displayed smaller to ensure they fit within the standard-sized browser window]
  • max-height: 750px [prevents images that are too tall from being cut-off]
  • Note: In the example above, there is a shadow applied to this CSS Rule. Dreamweaver does not yet support all the new CSS3 features, therefore to add the box-shadow effect one must manually add the CSS code into the #lightbox img rule. The shadow-box CSS rules are listed below. To access the necessary code, right click on the rule in the CSS Styles panel and choose “Go to code”, place the cursor onto a new line and enter the code below.
    • box-shadow:0 0 25px #111;
    • -webkit-box-shadow:0 0 25px #111;
    • -moz-box-shadow:0 0 25px #111;
Posted in Adobe Dreamweaver jQuery

5 Comments to Dreamweaver Tutorial: Add a jQuery Lightbox to Dreamweaver websites

  1. Jesenia's Gravatar Jesenia
    January 20, 2016 at 11:00 am | Permalink

    Thank you this was very helpful.

  2. Byron's Gravatar Byron
    October 29, 2016 at 8:17 am | Permalink

    followed these instructions to the letter and they are not working.

  3. Mark's Gravatar Mark
    January 24, 2017 at 12:39 am | Permalink

    I did too it wont work properly for some reason

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Featured Clients

Northwestern University Wildcat Sports Camp


Take the first step

Questions? Give us a ring, shoot us an email or send a homing pigeon our way. Let’s get the ball rolling! We can’t wait to hear from you!

Gecko Designs, LLC
523 N Higgins Ave
Missoula, MT 59802

(406) 662-1123

523 N Higgins Ave, Missoula
Michelle Levitus 5 months ago
Gecko Designs was a pleasure to work with while building out a brand new website. They understood what we were after and had creative and useful ideas to help us reach our goals for the website and for our organization. Communication was friendly and reliable throughout the process and they were available to troubleshoot any issues that arose before we went live, and after. Highly recommend!
Eric Halverson 3 months ago
Gabriel at Gecko Designs has proven over and over again that he and his team offer an incredible product to their clients (me!). I've been thrilled by his communication, the products they offer, and their responsiveness to my requests. Anyone looking for a website, logo, etc.. would be making a no-brainer decision to do business with Gecko Designs.
Martin Judnich 7 months ago
From intro meeting to final website, this was a great experience. Gecko created exactly what I was looking for, and was very timely and affordable. Great collaboration, lots of changes, and they made me feel comfortable every step of the way. I could not recommend more.
Lincoln Mansch 10 months ago
Our non-profit organization can't find enough adjectives to describe the top-notch, professional, and amazing work Gabe and his team provides. They have been amazing supporters of our organization from answering simple quick questions, to volunteering at our events, to helping us with graphic designs and website updates for our biggest event, to helping us with the mother of all projects....redesigning our very outdated website. We are always amazed at how quickly and efficiently they work despite us coming back with little nit-picky changes and requests. We often wonder if we're their only client because they are so quick to respond....but that is exactly how they want you to feel - as if you are their only/most important client. They are always willing to do whatever it takes to get the job done right by taking very careful consideration of their clients' needs, wants, and desires, and end up producing work that is nothing short of brilliant.
Jaycie Loney a year ago
Gabe and his team did a great job helping us with our fundraiser. They were the most affordable, easiest to work with place in town! We couldn't have been more pleased with these guys!! Highly Recommended!