RUSSEL86

custom popup/ arrow animation/ div clone

Nov 19th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.10 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <meta charset=utf-8 />
  5.     <title>ColorBox demo</title>
  6.     <style type="text/css">
  7.     *{
  8.         box-sizing: border-box;
  9.     }
  10.         img{
  11.             max-width:100%;
  12.         }
  13.         .popup{
  14.             background: rgba(4, 4, 4, 0.5);
  15.             padding: 50px 0px;
  16.             position: fixed;
  17.             top: 0;
  18.             left: 0;
  19.             width: 100%;
  20.             height: 100%;
  21.             /*opacity: 0;*/
  22.             /*visibility: hidden;*/
  23.             display:none;
  24.         }
  25.         .popup.active{
  26.             opacity: 1;
  27.             visibility: visible;
  28.         }
  29.         .container{
  30.             width:1000px;
  31.             margin: 0 auto;
  32.             position:relative;
  33.         }
  34.         .arrow{}
  35.         .arrow span{
  36.             transition:all 0.5s;
  37.             display: inline-block;
  38.         }
  39.         .arrow.active span{
  40.             transform: rotate(180deg);
  41.         }
  42.        
  43.     </style>
  44.   </head>
  45.   <body>
  46.     <h1>Hello, there!</h1>
  47.     <h2>This is some content</h2>
  48.     <p>The popup will open in five seconds</p>
  49.     <button id="button" >Popup</button>
  50.     <div id="popup" class="popup">
  51.         <div class="container">
  52.             <button id="close">X</button>
  53.             <div class="row">
  54.                 <img src="natur.jpg" alt="" />
  55.             </div>
  56.         </div>
  57.     </div>
  58.     <hr />
  59.     <a class="lightbox" href="natur.jpg">Popup</a> | <a class="lightbox" href="trusticonscolor.png">Popup 2</a>
  60.     <div id="lightbox-container" class="popup">
  61.         <div class="container">
  62.             <button class="close">X</button>
  63.             <div class="row">
  64.                 <img class="image" src="" alt="" />
  65.             </div>
  66.         </div>
  67.     </div>
  68.     <hr />
  69.     <button class="arrow">click <span>^</span></button>
  70.     <hr />
  71.     <div id="count">0</div>
  72.     <ul id="countbox">
  73.        
  74.     </ul>
  75.     <hr />
  76.     <ul id="content">
  77.         <li>List Content 1 <button class="add">+</button></li>
  78.         <li>List Content 2 <button class="add">+</button></li>
  79.         <li>List Content 3 <button class="add">+</button></li>
  80.         <li>List Content 4 <button class="add">+</button></li>
  81.         <li>List Content 5 <button class="add">+</button></li>
  82.         <li>List Content 6 <button class="add">+</button></li>
  83.     </ul>
  84.  
  85.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  86.     <script>
  87.         $(document).ready(function() {
  88.             $("#button").click(function() {
  89.                 //$("#popup").addClass("active");
  90.                 $("#popup").fadeIn();
  91.             });
  92.             $("#close").click(function() {
  93.                 //$("#popup").removeClass("active");
  94.                 $("#popup").fadeOut();
  95.             });
  96.             // Lightbox
  97.             $(".lightbox").click(function(e) {
  98.                 e.preventDefault();
  99.                 var link = $(this).attr("href");
  100.                 $("#lightbox-container").find(".image").attr('src', link);
  101.                 $("#lightbox-container").fadeIn();
  102.             });
  103.             $(".close").click(function() {
  104.                 $("#lightbox-container").fadeOut();
  105.             });
  106.             // Arrow animation
  107.             $(".arrow").click(function() {
  108.                 $(this).toggleClass("active");
  109.             });
  110.             // Add content
  111.             var count = 0;
  112.             $(".add").click(function() {
  113.                 var clone = $(this).parent().clone();
  114.                 $("#countbox").append(clone);
  115.                 $("#countbox").find("button").removeClass("add").addClass("remove").text("-");
  116.                 count = count+1;
  117.                 $("#count").text(count);
  118.             });
  119.             $("#countbox").on( 'click','.remove', function() {
  120.                 $(this).parent().remove();
  121.                 count = count-1;
  122.                 $("#count").text(count);
  123.             });
  124.         });
  125.     </script>
  126.   </body>
  127. </html>
Advertisement
Add Comment
Please, Sign In to add comment