Advertisement
Guest User

Slideshow with changing background

a guest
Aug 22nd, 2013
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.61 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <meta name="keywords" content="web design, website development, web application development, print design, database development, ecommerce websites, search engine optimization, packaging design" />
  6. <meta name="description" content="Design Chemical, Bangkok provides web design, website development, web application development, print design, database development, ecommerce websites, search engine optimization &amp; packaging design." />
  7. <meta name="robots" content="all" />
  8. <title>jQuery Demo - Ultimate Image Swap Gallery</title>
  9. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  10.  
  11. <style type="text/css">
  12. body,html,div,blockquote,img,label,p,h1,h2,h3,h4,h5,h6,pre,ul,ol,li,dl,dt,dd,form,a,fieldset,input,th,td{border:0;outline:none;margin:0;padding:0;}
  13. ul{list-style:none;}
  14.  
  15. #gallery {position: absolute; z-index: 1; width: 660px; margin: 0 auto; left: 50%; margin-left: -330px;}
  16. #gallery ul {padding-left: 10px;}
  17. #gallery li {display: inline; margin-right: 3px;}
  18. #gallery li:hover {cursor: pointer;}
  19. #gallery #main-img {background: url("bg_img.png") no-repeat 0 0; padding: 26px;}
  20. #bgs {position: absolute; z-index: 0; width: 100%; height: 100%; background: url("gallery/bgs/img_1.jpg");}
  21. </style>
  22. <script type="text/JavaScript">
  23. // prepare the form when the DOM is ready
  24. $(document).ready(function() {
  25.     $("#gallery li img").click(function(){
  26.         $('#main-img').attr('src',$(this).attr('src').replace('thumb/', ''));
  27.         $('#bgs').css('background-image','url(gallery/bgs/img_3.jpg)');
  28.     });
  29.     var imgSwap = [];
  30.      $("#gallery li img").each(function(){
  31.         imgUrl = this.src.replace('thumb/', '');
  32.         imgSwap.push(imgUrl);
  33.     });
  34.     $(imgSwap).preload();
  35. });
  36. $.fn.preload = function() {
  37.     this.each(function(){
  38.         $('<img/>')[0].src = this;
  39.     });
  40. }
  41. </script>
  42. </head>
  43. <body>
  44.     <div id="bgs"></div>
  45.     <div id="gallery">
  46.         <img src="gallery/img_1.jpg" alt="" id="main-img" />
  47.         <ul>
  48.             <li><img src="gallery/thumb/img_1.jpg" alt="" /></li>
  49.             <li><img src="gallery/thumb/img_2.jpg" alt="" /></li>
  50.             <li><img src="gallery/thumb/img_3.jpg" alt="" /></li>
  51.             <li><img src="gallery/thumb/img_4.jpg" alt="" /></li>
  52.             <li><img src="gallery/thumb/img_5.jpg" alt="" /></li>
  53.             <li><img src="gallery/thumb/img_6.jpg" alt="" /></li>
  54.         </ul>
  55.     </div>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement