Jquery Scroller With Lightbox

This is a simple Jquery Slider that works with a lightbox using animate.

Click the thumbs to open in a lightbox

Hope this helps you, please leave comments below on how to improve this or just to say Hi

Result

click to enlarge
left right
  • click to enlarge
  • click to enlarge
  • click to enlarge
  • click to enlarge
  • click to enlarge
  • click to enlarge
  • click to enlarge
  • click to enlarge
  • click to enlarge
  • click to enlarge
  • click to enlarge
  • click to enlarge
 <!DOCTYPE html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link href="css/layout.css" rel="stylesheet" type="text/css" />
  <title>Lightbox Demo</title>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  <style type="text/css">
  /*lightbox css*/
  body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  color: #000000;
  text-align: center;
  margin: 0px;
  padding: 0px;
  background-color: #333333;
  }
  ul {
  margin: 0px;
  padding: 0px;
  }
  #container {
  width: 980px;
  color: #fff;
  padding: 0px;
  text-align: left;
  margin-top: 0px;
  margin-right: auto;
  margin-bottom: 0px;
  margin-left: auto;
  }
  #content {
  width: 100%;
  text-align: justify;
  line-height: 1.4;
  margin: 0px;
  padding-top: 10px;
  padding-right: 0px;
  padding-bottom: 10px;
  padding-left: 0px;
  }
  #position {
  position: absolute;
  margin: 0px;
  padding: 0px;
  }
  #thumbs {
  position: absolute;
  z-index: 500;
  height: 42px;
  width: 42px;
  overflow: hidden;
  padding: 0px;
  margin-right: 0px;
  margin-bottom: 0px;
  margin-left: 0px;
  left: 760px;
  top: 0px;
  border: none;
  margin-top: 0px;
  z-index: 1001;
  }
  .overlay {
  position: absolute;
  height: 100%;
  width: 100%;
  background: #000;
  z-index: 50;
  cursor: pointer;
  margin: 0px;
  padding: 0px;
  }
  .overlay img {
  border-top-width: 42px;
  border-right-width: 10px;
  border-bottom-width: 42px;
  border-left-width: 10px;
  border-top-style: solid;
  border-right-style: solid;
  border-bottom-style: solid;
  border-left-style: solid;
  border-top-color: #FF0000;
  border-right-color: #FF0000;
  border-bottom-color: #FF0000;
  border-left-color: #FF0000;
  margin: 0px;
  padding: 0px;
  }
  #thumb {
  padding: 0;
  margin-top: 0;
  margin-right: 0;
  margin-bottom: 10px;
  margin-left: 0;
  overflow: visible;
  width: 99999999px;
  }
  #thumb li {
  list-style-type: none;
  display: inline;
  margin-right: 10px;
  padding: 0px;
  margin-top: 0px;
  margin-bottom: 0px;
  margin-left: 0px;
  }
  .thumb {
  margin-bottom: 10px;
  padding: 0px;
  margin-top: 0px;
  margin-right: 0px;
  margin-left: 0px;
  }
  img {
  border: none;
  margin: 0;
  padding: 0;
  }
  #image {
  margin-bottom: 10px;
  -moz-box-shadow: -5px 5px 5px 1px #464747;
  -webkit-box-shadow: -5px 5px 5px 1px #464747;
  box-shadow: -5px 5px 5px 1px #464747;
  padding: 0px;
  margin-top: 0px;
  margin-right: 0px;
  margin-left: 200px;
  }
  #title {
  width: 980px;
  top: 50px;
  margin-right: auto;
  margin-left: auto;
  text-align: center;
  position: absolute;
  padding: 0px;
  margin-top: 0px;
  margin-bottom: 0px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  color: #000;
  }
  #popup {
  posistion: relative;
  width: 980px;
  top: 50px;
  margin-right: auto;
  margin-left: auto;
  text-align: center;
  padding: 0px;
  margin-top: 0px;
  margin-bottom: 0px;
  }
  img#x {
  position: absolute;
  left: 460px;
  top: 0px;
  border: none;
  }
  #bg {
  background-color: #000000;
  height: 100%;
  width: 100%;
  position: absolute;
  left: 0px;
  top: 0px;
  opacity: 0.9;
  z-index: 50;
  display: none;
  }
  /*scroller css*/
  #slidesWrapper {
  width: 580px;
  height: 180px;
  margin-right: auto;
  margin-left: auto;
  position: relative;
  padding: 0px;
  margin-top: 0px;
  margin-bottom: 0px;
  overflow: hidden;
  }
  .slides {
  position: relative;
  left: 0px;
  top: 0px;
  margin: 0px;
  padding: 0px;
  width: 140px;
  height: 500px;
  }
  .slides div {
  width: 400000px;
  margin: 0px;
  padding: 0px;
  }
  .slides img {
  margin: 0px;
  padding: 0px;
  }
  .slideImg {
  width: 135px;
  height: 100px;
  margin: 0px;
  padding: 0px;
  display: inline;
  float: left;
  }
  img {
  border: none;
  margin: 0px;
  padding: 0px;
  }
  #left {
  position: absolute;
  top: 80px;
  left: 200px;
  z-index: 1500;
  margin: 0px;
  padding: 0px;
  }
  #right {
  position: absolute;
  top: 80px;
  left: 300px;
  z-index: 1500;
  margin: 0px;
  padding: 0px;
  }
  </style>
  </head> 
  <body>
  <script type="text/javascript">
  
  $(document).ready(function() {
  //lightbox 
  $("#thumb a").on('mouseover touchend', function()  {// mouseover the thumbs
  var x=$("img", this).attr("src");// x= the src value of the image the mouse is over
  title=$("img",this).attr("title");
 $("#image").attr("src", x);//swap the main image with the value of the thumb
  })
  $("#thumb a").click(function() { // if we click on the thumb
  
  $('#popup').hide().one('load', function() {//load the pop up div with the main image and hide it
  }).attr('src', image);
  
  thumbs=$("img", this).attr("src");//thumbs is the src value
  var paths = [thumbs];
  $.each(paths, function(i, path) {
  var img = new Image();
  $(img).load(function() {
  var width = img.width,
  height = img.height;

  $("#popup").hide().fadeIn(2000).html("<img src='images/x.png' alt= 'click to close' title='click to close' id='x'/><img src=" + thumbs + " width="+width+" height="+height+" id='large' title='Click The X To Close' alt='Click The X To Close' /> <p id='title'><strong>"+title+"</strong></p>");
  $("#title").css("top", height+50);
  $("#thumbs").css("left", width);
  });
  img.src = path;
  });
  $("#bg").css("display", "block");
  $("#bg").css("opacity", "0.8");
  $("#popup").addClass("overlay");
  })
  
  $("#x").live("click", function() {
  $("#content").css("visibility","visible");
  $("body").css("background", "#333333");
  $("#bg").css("display", "none");
  
  $('#popup').hide();
  });
  //scroller//////////////////////////////////////////////////////////////////////////////////Scroller
  $('iframe').each(function(){///////this makes u tube video accept its z-index;
  var url = $(this).attr("src");
  var char = "?";
  if(url.indexOf("?") != -1)
  var char = "&";
  $(this).attr("src",url+char+"wmode=transparent");
  });
  
  //////ends u tube z-index
  
  $("#left").mouseover(function(){//prevents flashing of arrows when images change
  $("#left").show();
  $("#right").show();
  });
  
  $("#right").mouseover(function(){//prevents flashing of arrows when images change
  $("#left").show();
  $("#right").show();
  });
  
  $(".slideImg").mouseover(function(){// pause on over image slider
  clearInterval(interval);
  $("#left").show();
  $("#right").show();
  });
  $(".text").mouseover(function(){// pause on over of none image slider
  clearInterval(interval);
  $("#left").show();
  $("#right").show();
  });
  
  $("#slidesWrapper").mouseover(function(){//so the images will display if not over an image
  $("#left").show();
  $("#right").show();
  });
  
  $(".slideImg").mouseout(function(){// hide the arrows when not over the image
  $("#left").hide();
  $("#right").hide();
  interval = setInterval(function() {// animate every 5 seconds
  right();//call the right function
  }, 5000);
  });
  
  $(".text").mouseout(function(){// hide the arrows when not over the text
  $("#left").hide();
  $("#right").hide();
  interval = setInterval(function() {// animate every 5 seconds
  right();//call the right function
  }, 5000);
  }); 
  
  $("#slidesWrapper").mouseout(function(){//so the images will display if not over an image
  $("#left").hide();
  $("#right").hide();
  }); 
  
  function right() {// create a function for the right arrow clicked and the animation on load
  if(count<slideImg) {//if slide number is less than number of slides continue
  count++; //increase the slide number by 1
  $(".slides").animate({"left": "-=135px"}, "slow");// move the slide
  }
  else {// if were on the last slide
  var back=slideImg * 135 - 135; //calculate the pixels to animate
  $(".slides").animate({"left": "+="+back+"px"}, "fast");// go to first slide
  count=1;// set the slide number to 1
  } 
  }// end right function
  
  var count=1;// get the first slide number
  var slideImg=$(".slideImg").length;//number of slides with clas slideShow
  var text=$(".text").length;// number of slides not images
  slideImg=slideImg+text;// total number of slides
  //Start Animation
  
  var interval = setInterval(function() {// animate every 5 seconds
  right();//call the right function
  }, 5000);
  //end animation
  
  //if arrows are clicked
  $("#right").click(function(){
  right(); // call the right arrow function
  });
  
  $("#left").click(function(){// if left arrow is clicked
  if(count>1) {// if the slide is not the first
  count--;// let the slide number decrease by 1
  $(".slides").animate({"left": "+=135px"}, "slow");// move the slide
  }
  });
  
  
  });
  </script>
  <div id="container">
  <div id="bg"></div>
  <div id="position">
  <div id="popup"></div>
  </div>
  <div id="content"> <img src="images/image1.jpg" title="click image to enlarge" alt="click to enlarge" width="582" height="360"  id="image"/>
  <div id="slidesWrapper"> <img src="images/left.png" width="100" alt="left" id="left" /> <img src="images/right.png" width="100" alt="right" id="right" />
  <div class="slides">
  <div>
  <ul id="thumb">
  <li><a href="#"><img class="thumb slideImg" src="images/image1.jpg" alt="click to enlarge" title="car 1 " width="135" height="100" id="first"/></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image2.jpg" alt="click to enlarge" title="car2" width="135" height="100" /></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image3.jpg" alt="click to enlarge" title="car3" width="135" height="100" /></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image4.jpg" alt="click to enlarge" title="car4" width="135" height="100" /></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image1.jpg" alt="click to enlarge" title="car 1 " width="135" height="100" /></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image2.jpg" alt="click to enlarge" title="car2" width="135" height="100" /></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image3.jpg" alt="click to enlarge" title="car3" width="135" height="100" /></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image4.jpg" alt="click to enlarge" title="car4" width="135" height="100" /></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image1.jpg" alt="click to enlarge" title="car 1 " width="135" height="100" /></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image2.jpg" alt="click to enlarge" title="car2" width="135" height="100" /></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image3.jpg" alt="click to enlarge" title="car3" width="135" height="100" /></a></li>
  <li><a href="#"><img class="thumb slideImg" src="images/image4.jpg" alt="click to enlarge" title="car4" width="135" height="100" /></a></li>
  </ul>
  </div>
  </div>
  </div>
  </div>
  <!--content--> 
  </div>
  <!--container-->
  </body>
  </html>

Available For Freelance:

I Am Available To Work For You Freelance, See My Skills To See If I Can Help Your Project, If I Can Help You Then Please Contact Me.

My Rates Start From £180 A Day, Discount Prices For Regular Clients And Work Over 3 Days.

I Started To Learn Web Development In 2008, I Did A Few Open University Courses While Working Full Time In The Building Trade, I Managed To Get A Diploma With Distinction

Request A Tutorial

If You Are Having Difficulty With The Development Of Your Website Or If You Are Just Starting Out Leaning Web Development And You Think I Can Help You Then Request A Tutorial, I Will Do My Best To Help You

I Dont Charge For My Services If I Can Help You With Something That Can Be Be Fixed In A Few Minutes.

Advertise

If You Would Like To Advertise On This Site Then Please Contact Me, You Will Be Given Login Details To See What Day And Where Clicks Have Come From.

Prices Start From £10 A Month With Discounts Available For 3 Months Or More.

You Can Either Send Me The Banner Advert That You Have Designed Or From £10 I Can Have Designer Design A Banner For You.

Please Leave A Comment And A Rating





image

Chris Gave This Code Rating

A Simple Lightbox scroller that woks the same as the other lightbox effects but you can use a left and right arrow controller

www.codecaven.co.uk image 5.00 out of 5 based on 1 ratings. 1 user reviews.

My Skills:

  • PHP 5
  • JavaScript
  • Jquery
  • XHTML Validation
  • KineticJS
  • HTML5
  • CSS - CSS3
  • SEO

My Social Networks:

  • facebook youtube