"light box img"
Bootstrap 3.0.0 Snippet by evarevirus

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html><html class=''> <head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/humbl3man/pen/CuqIl?q=gallery&limit=all&type=type-pens" /> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel='stylesheet prefetch' href='//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'> <style class="cp-pen-styles">body{ background-color: #4e5d6a; font-family: "Open Sans", sans-serif; } .container{ max-width: 800px; margin: 5% auto; padding: 20px; background-color: #fff; border-radius: 10px; overflow: hidden; box-sizing: border-box; box-shadow: 0 0 5px #222; } .text-center{ text-align: center; margin-bottom: 1em; } .lightbox-gallery { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; } .lightbox-gallery div > img { max-width: 100%; display: block; } .lightbox-gallery div { margin: 10px; flex-basis: 180px; } @media only screen and (max-width: 480px) { .lightbox-gallery { flex-direction: column; align-items: center; } .lightbox > div { margin-bottom: 10px; } } /*Lighbox CSS*/ .lightbox{ display: none; width: 100%; height: 100%; background-color: rgba(0,0,0,.7); position: fixed; top: 0; left: 0; z-index: 20; padding-top: 30px; box-sizing: border-box; } .lightbox img{ display: block; margin: auto; } .lightbox .caption{ margin: 15px auto; width: 50%; text-align: center; font-size: 1em; line-height: 1.5; font-weight: 700; color: #eee; }</style></head><body> <div class="container"> <h2 class="text-center">Lightbox Gallery</h2> <div class="lightbox-gallery"> <div><img src="https://placehold.it/300/f1b702/fff&text=image1" alt="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reprehenderit, quae, quam. Ut dolorum quia, unde dicta at harum porro officia obcaecati ipsam deserunt fugit dolore delectus quam, maxime nisi quo."></div> <div><img src="https://placehold.it/300/d2f1b2/222&text=image2" alt="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maxime accusamus officiis dignissimos doloribus consectetur harum eos sapiente optio aut minima."></div> <div><img src="https://placehold.it/300/eee/000&text=image3" alt="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates veritatis similique, amet, maiores soluta recusandae cupiditate, sed perspiciatis fugit minima, sunt dolores cum earum deserunt illo ipsum!"></div> <div><img src="https://placehold.it/300/222/fff&text=image4" alt="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque laudantium dignissimos tenetur eos unde quidem repellat officiis nemo laboriosam necessitatibus deleniti commodi quis aliquid est atque tempora aut, nihil!"></div> <div><img src="https://placehold.it/300/b47f99/000&text=image5" alt="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Architecto minus consequatur soluta quaerat itaque, laboriosam quis a facilis, cumque, deleniti quas aperiam voluptate dolore. Enim nostrum sit eaque, porro eligendi illo placeat?"></div> <div><img src="https://placehold.it/300/e1d400/000&text=image6" alt="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sequi suscipit quam, id aliquam totam aperiam quas rem debitis voluptatem pariatur, illo accusamus facilis eius ipsa! Reprehenderit libero, quas iste repudiandae distinctio, quos dignissimos."></div> </div> </div> <script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script><script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script >// Create a lightbox (function() { var $lightbox = $("<div class='lightbox'></div>"); var $img = $("<img>"); var $caption = $("<p class='caption'></p>"); // Add image and caption to lightbox $lightbox .append($img) .append($caption); // Add lighbox to document $('body').append($lightbox); $('.lightbox-gallery img').click(function(e) { e.preventDefault(); // Get image link and description var src = $(this).attr("src"); var cap = $(this).attr("alt"); // Add data to lighbox $img.attr('src', src); $caption.text(cap); // Show lightbox $lightbox.fadeIn('fast'); $lightbox.click(function() { $lightbox.fadeOut('fast'); }); }); }()); //# sourceURL=pen.js </script> </body></html>

Related: See More


Questions / Comments: