"Bootstrap Lightbox"
Bootstrap 3.1.0 Snippet by harryward

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.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 ----------> <div class="container"> <div id="lightbox" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> <div class="modal-dialog"> <button type="button" class="close hidden" data-dismiss="modal" aria-hidden="true">×</button> <div class="modal-content"> <div class="modal-body"> <h2>Demo Lightbox Ad</h2> <img src="http://placehold.it/600x300" alt="" /> </div> </div> </div> </div> <script> $(document).ready(function() { var $lightbox = $('#lightbox'); $('[data-target="#lightbox"]').on('click', function(event) { var $img = $(this).find('img'), src = $img.attr('src'), alt = $img.attr('alt'), css = { 'maxWidth': $(window).width() - 100, 'maxHeight': $(window).height() - 100 }; $lightbox.find('.close').addClass('hidden'); $lightbox.find('img').attr('src', src); $lightbox.find('img').attr('alt', alt); $lightbox.find('img').css(css); }); $lightbox.on('shown.bs.modal', function (e) { var $img = $lightbox.find('img'); $lightbox.find('.modal-dialog').css({'width': $img.width()}); $lightbox.find('.close').removeClass('hidden'); }); $('#lightbox').modal(); }); </script> <style>body { padding: 30px 0px; } #lightbox .modal-content { display: inline-block; text-align: center; } </style>

Related: See More


Questions / Comments:

Hey his is such a wonderful work, is there a way you could make the pop up programmatic, such that it could pop up after say 3 seconds or after 10 seconds,
Thank you.

biggy87olw () - 6 years ago - Reply 0