Advertisement
AmourSpirit

Working lightbox example

Dec 22nd, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.99 KB | None | 0 0
  1.  <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
  6. <title>Lightbox Test</title>
  7.     <style type="text/css">
  8.  
  9.         body
  10.         {
  11.             font-family: Helvetica, Arial;
  12.         }
  13.  
  14.         .backdrop
  15.         {
  16.             position:absolute;
  17.             top:0px;
  18.             left:0px;
  19.             width:100%;
  20.             height:100%;
  21.             background:#000;
  22.             opacity: .0;
  23.             filter:alpha(opacity=0);
  24.             z-index:50;
  25.             display:none;
  26.         }
  27.  
  28.  
  29.         .box
  30.         {
  31.             position:absolute;
  32.             top:20%;
  33.             left:30%;
  34.             width:500px;
  35.             height:300px;
  36.             background:#ffffff;
  37.             z-index:51;
  38.             padding:10px;
  39.             -webkit-border-radius: 5px;
  40.             -moz-border-radius: 5px;
  41.             border-radius: 5px;
  42.             -moz-box-shadow:0px 0px 5px #444444;
  43.             -webkit-box-shadow:0px 0px 5px #444444;
  44.             box-shadow:0px 0px 5px #444444;
  45.             display:none;
  46.         }
  47.  
  48.         .close
  49.         {
  50.             float:right;
  51.             margin-right:6px;
  52.             cursor:pointer;
  53.         }
  54.  
  55.         </style>
  56.  
  57.         <script type="text/javascript">
  58.            
  59.             jQuery(document).ready(function(){
  60.                
  61.                 jQuery('.lightbox').click(function(){
  62.                     jQuery('.backdrop, .box').animate({'opacity':'.50'}, 300, 'linear');
  63.                     jQuery('.box').animate({'opacity':'1.00'}, 300, 'linear');
  64.                     jQuery('.backdrop, .box').css('display', 'block');
  65.                 });
  66.  
  67.                 jQuery('.close').click(function(){
  68.                     close_box();
  69.                 });
  70.  
  71.                 jQuery('.backdrop').click(function(){
  72.                     close_box();
  73.                 });
  74.  
  75.             });
  76.  
  77.             function close_box()
  78.             {
  79.                 jQuery('.backdrop, .box').animate({'opacity':'0'}, 300, 'linear', function(){
  80.                     jQuery('.backdrop, .box').css('display', 'none');
  81.                 });
  82.             }
  83.  
  84.         </script>
  85. </head>
  86. <body>
  87.  
  88.     <h1>Lightbox Example</h1>
  89.     <a href="http://www.tonylea.com/2011/how-to-create-your-own-jquery-lightbox/" target="_blank">See Tonylea.com</a>
  90.     <br />
  91.     <a href="#" class="lightbox">Open Lightbox</a>
  92.  
  93.     <div class="backdrop"></div>
  94.     <div class="box"><div class="close">x</div>This is the lightbox!!!</div>
  95.  
  96.     </body>
  97. </body>
  98. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement