"light box"
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 lang='en' 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/pablojaeger/pen/RRzBow?depth=everything&order=popularity&page=56&q=thumbnail&show_forks=false" /> <style class="cp-pen-styles">@import 'https://fonts.googleapis.com/css?family=Raleway'; html *{ -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; margin: 0; padding: 0; } body{ margin: 0; padding: 0; font-family: 'Raleway', sans-serif; } .auto-lightbox{ width: 100%; margin: 0 auto; overflow: hidden; padding: 0; font-size: 0; } .auto-lightbox .easing{ -webkit-transition: all 0.25s ease-in-out; -moz-transition: all 0.25s ease-in-out; -o-transition: all 0.25s ease-in-out; transition: all 0.25s ease-in-out; } .auto-lightbox .list{ list-style: none; display: block; text-align: center; padding: 10px 0; /* background: #f0f0f0; */ } body{ font-family: 'Raleway', sans-serif; } .auto-lightbox .list .item{ /* float: left; */ display: inline-block; } .auto-lightbox .thumbnail{ width: 150px; height: 150px; display: table; float: left; position: relative; color: inherit; border: none !important; padding: 0 !important; overflow: hidden; margin: 10px; vertical-align: middle; text-decoration: none; background-size: cover; background-color: #DDD; background-position: center; background-repeat: no-repeat; z-index: 0; -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); -moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.25); text-shadow: 2px 2px 0px #000000; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; } .auto-lightbox .thumbnail:hover > span{ opacity: 1; } .auto-lightbox .thumbnail > span{ width: 100%; height: 100%; display: table-cell; position: relative; z-index: 1; padding: 15px; text-align: center; background-color: rgba(0,0,0,0.5); font-weight: 700; font-size: 20px; line-height: 24px; color: #FFF; opacity: 0; vertical-align: middle; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); } .auto-lightbox .large{ position: fixed; width: 100%; height: 0; overflow: hidden; top: 0; left: 0; padding: 0; float: left; opacity: 1; } .auto-lightbox .large > .overlay{ background-color: rgba(0,0,0,0.75); position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; } .auto-lightbox .img-area{ position: relative; font-size: 0; width: 450px; max-width: 100%; height: auto; margin: 0 auto; display: block; opacity: 0; -webkit-transform: scale(1.5); -moz-transform: scale(1.5); -o-transform: scale(1.5); -ms-transform: scale(1.5); transform: scale(1.5); } .auto-lightbox .img-box{ position: relative; width: 100%; height: 100%; } .auto-lightbox .img-box > img{ position: relative; width: 100%; height: auto; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; } .auto-lightbox .img-area > h3{ margin: 10px 0 0px 0; font-size: 25px; line-height: 30px; font-weight: 700; color: #EEE; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); } .auto-lightbox .img-area > p{ margin: 0 0 10px 0; font-size: 16px; line-height: 25.6px; font-weight: 400; color: #BBB; } .auto-lightbox .img-area > h3:empty, .auto-lightbox .img-area > p:empty{ display:none; } .auto-lightbox .img-box > .arrow{ position: absolute; display: block; line-height: 0; text-align: center; width: 25%; height: 100%; margin-top: 0; top: 0; font-size: 0; text-decoration: none; opacity: 0; } .auto-lightbox .img-box > .arrow.left{ right: 100%; margin-right: -25%; cursor: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAdBAMAAAHJhqokAAAAKlBMVEX///////////////////////////////////////////////////////9q+00tAAAADXRSTlMAEB8wYGqgstDc7fD2vWP3WQAAAGFJREFUGNNjYBBg4GVAAhdAXAgCcSCAjYEhkYFNgKGQgUGEgYHRAUKBZHIFUAjdALB6WQdMigNE3ABi3gasjLNgRWAbe3EzmWEuupsAYzQSz+CEMRiY1l6B+ZixlzxmtwEAEtoiRddNcp8AAAAASUVORK5CYII=), auto; } .auto-lightbox .img-box > .arrow.right{ left: 100%; margin-left: -25%; cursor: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAdBAMAAAHJhqokAAAALVBMVEX///////////////////////////////////////////////////////////+g0jAFAAAADnRSTlMAEDBASldgnKDQ2fDx/pJ1BNAAAABnSURBVBjTY2BgYOBmQAJ8DA8gAiDiAURsA4QHpHgYGMQYGBOABIMBUHADWBqVkisAEQkoBEMSiNBTABJMj7Ayn4CY64CYE2TnPKwMCJB+rQBjapPH1HkbAGEwznsOYzwjnsHAAWMAAM+1JERQZw1AAAAAAElFTkSuQmCC), auto; /*cursor: url("next.png"), auto;*/ } .auto-lightbox .large:target { display: block; padding: 110px 40px 120px 40px; z-index: 1; height: 100%; overflow-y: auto; } .auto-lightbox .large:target > .overlay { opacity: 1; position: fixed; cursor: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAXBAMAAAGKwZI7AAAAJ1BMVEX///////////////////////////////////////////////////9Ruv0SAAAADHRSTlMAECAwQFBgcICg0PDDwQf4AAAAoklEQVQY00VNuRHCMBBc4cxyQOxRQB9SQAEElCCGlApogcQlmNwBBRA4cqSivKsHNHO3z+2dAGBgrcARFvhIsn1FNQBmDvuaGXrBjIXSUi+5E3O3699v78Q6ABshXOEiOlKzIUQ67i4fJkmgKxBuMhljWDGG87o752MGeMR63L8xliV4YRG+WBKVSrwaBS5patSnZ/OVrdfKWhbtgsTv33HaAbKUNeliBt8DAAAAAElFTkSuQmC), auto; } .auto-lightbox .large:target > .img-area{ opacity: 1; -webkit-transform: scale(1); -moz-transform: scale(1); -o-transform: scale(1); -ms-transform: scale(1); transform: scale(1); } .auto-lightbox .img-box > .arrow::before, .auto-lightbox .img-box > .arrow::after{ content: ""; width: 4px; height: 20px; background: #FFF; display: block; position: absolute; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; padding: 0; font-size: 0; line-height: 0; top: 50%; left: 50%; margin: -10px 0 0 -2px; opacity: 1; -webkit-transition: all 0.75s ease-in-out; -moz-transition: all 0.75s ease-in-out; -o-transition: all 0.75s ease-in-out; transition: all 0.75s ease-in-out; /* -webkit-transform: rotate(135deg); -moz-transform: rotate(135deg); -o-transform: rotate(135deg); -ms-transform: rotate(135deg); transform: rotate(135deg); */ } .auto-lightbox .img-box > .arrow::before, .auto-lightbox .img-box > .arrow::after{ top: 0; margin: 60px 0 0 -2px; } .auto-lightbox .img-box > .arrow.left::before, .auto-lightbox .img-box > .arrow.right::after{ -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); -o-transform: rotate(-45deg); -ms-transform: rotate(-45deg); transform: rotate(-45deg); } .auto-lightbox .img-box > .arrow.left::after, .auto-lightbox .img-box > .arrow.right::before{ -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -o-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); } .auto-lightbox .img-box > .arrow.left::before{ margin-top: 72px; } .auto-lightbox .img-box > .arrow.right::before{ margin-top: 72px; } </style></head><body> <html lang="pt-BR"> <head> <meta charset="UTF-8"> <title>Auto Lightbox</title> <link rel="stylesheet" href="styles.css"> </head> <body> <section class="auto-lightbox"> <img src="https://s10.postimg.org/9pjh0aj15/lightbox01.png" alt="Marcação Simplificada: Apenas imagens inseridas dentro do elemento pai 'auto-lightbox'"> <img src="https://s10.postimg.org/nkhrirdg9/lightbox02.png" alt="Inicialização Simplificada: Basta adicionar o script 'auto-lightbox.js' e chamar a função 'autoLightBox', passando como parâmetro o objeto que deverá abrigar o lightbox"> <img src="https://s10.postimg.org/k25rmdck9/lightbox03.png" alt="Inicialização Simplificada: Basta adicionar o script 'auto-lightbox.js' e chamar a função 'autoLightBox', passando como parâmetro o objeto que deverá abrigar o lightbox"> <img src="https://s4.postimg.org/nppzw3q65/milky_way_1030765_960_720.jpg" alt="Via Láctea: pixabay.com"> <img src="https://s4.postimg.org/amyyqkpbx/stars_768708_960_720.jpg" alt="Céu noturno: pixabay.com"> <img src="https://s4.postimg.org/abhidt8vx/stars_821611_960_720.jpg" alt="Montanha e estrelas: pixabay.com"> <img src=https://s4.postimg.org/rktdyo9bx/milky_way_894237_960_720.jpg" alt="Galáxia: pixabay.com"> <img src="https://s4.postimg.org/8d6922r0d/delicate_arch_896885_960_720.jpg" alt="Montanha e estrelas 2: pixabay.com"> <img src="https://s4.postimg.org/5kd1i1qnx/international_space_station_1176518_960_720.jpg" alt="Terra vista do espaço: pixabay.com"> </section> <script src="auto-lightbox.js"></script> </body> </html> <script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script> <script >var scrollPosition = ""; var body = document.querySelector("body"); function autoLightBox(objeto){ var lightboxes = document.querySelectorAll(objeto); lightboxes.forEach(function(item, index){ let containerID = 'lightbox' + (index+1); item.setAttribute("id", containerID); let template = ""; let newHTML = ""; let imgs = item.querySelectorAll("img"); for (i=0; i< imgs.length; i++){if (window.CP.shouldStopExecution(1)){break;}if (window.CP.shouldStopExecution(1)){break;} let imgID = 'lightbox' + (index+1) + '_img'+(i+1); let imgURL = imgs[i].getAttribute("src"); let imgAltOriginal= imgs[i].getAttribute("alt"); let imgTitle = ""; let imgDescription = ""; let imgPrev = ""; let imgNext = ""; if(imgAltOriginal){ imgTitle = imgAltOriginal.split(": ")[0]; imgDescription = imgAltOriginal.split(": ")[1]; } if(i > 0 || i < (imgs.length - 1)) { imgPrev = 'lightbox' + (index + 1) + '_img' + i; imgNext = 'lightbox' + (index + 1) + '_img' + (i + 2); //console.log("i:" + i + " | " + "imgPrev:" + imgPrev + " | " + "imgNext: " + imgNext); } if(i == 0) { imgPrev = 'lightbox' + (index + 1) + '_img' + (i + imgs.length); //console.log("i:" + i + " | " + "imgPrev:" + imgPrev); } if(i == (imgs.length - 1)) { imgNext = 'lightbox' + (index + 1) + "_img" + (i - imgs.length + 2); //console.log("i:" + i + " | " + "imgNext: " + imgNext); } template = '<li class="item"><a href="#' + imgID + '" class="thumbnail" style="background-image: url(' + imgURL + ')"><span class="easing">' + imgTitle + '</span></a><div class="large" id="' + imgID + '"><a href="#' + 'lightbox' + (index + 1) + '" class="overlay"></a><div class="img-area easing"><div class="img-box"><img src="' + imgURL + '" alt="' + imgAltOriginal + '"><a href="#' + imgPrev + '" class="arrow left"></a><a href="#' + imgNext + '" class="arrow right"></a></div><h3>' + imgTitle + '</h3><p>' + imgDescription + '</p></div></div></li>' newHTML += template; lightboxes[index].innerHTML = '<ul class="list">' + newHTML + '</ul>'; } window.CP.exitedLoop(1); window.CP.exitedLoop(1); ; var links = document.querySelectorAll(".thumbnail"); links.forEach(function(link, count){ link.addEventListener("click", function(event){ scrollPosition = window.pageYOffset; }); }); }); }; autoLightBox(".auto-lightbox"); window.onhashchange = function(){ let urlImagem = location.hash; if (urlImagem.indexOf("_") != -1){ body.style.overflow = "hidden"; }else{ body.style.overflow = "visible"; } window.scrollTo(0, scrollPosition); }; //# sourceURL=pen.js </script> </body></html>

Related: See More


Questions / Comments: