纯CSS3 lightbox插件 a pure CSS lightbox (now with JavaScript)

perfundo

a pure CSS lightbox
(now with JavaScript)

About

perfundo is an extremely lightweight, pure CSS Lightbox which is completely functional without JavaScript. You can view the code on GitHub.

Demos

Single image

Demo image
Demo image
Single image with caption
Close
<div class="perfundo">
  <a class="perfundo__link" href="#perfundo-single2">
    <img src="img/img-single_s.jpg" alt="Demo image">
  </a>
  <div id="perfundo-single2" class="perfundo__overlay fadeInLeft">
    <figure class="perfundo__content perfundo__figure">
      <img src="img/img-single_s.jpg" alt="Demo image">
      <div class="perfundo__image" style="width: 800px; padding-top: 56.25%; background-image: url(img/img-single.jpg);"></div>
      <figcaption class="perfundo__figcaption">Single image with caption</figcaption>
    </figure>
    <a href="#perfundo-untarget" class="perfundo__close perfundo__control">Close</a>
  </div>
</div>
// No JavaScript!

Simple gallery

<div class="perfundo">
  <a class="perfundo__link" href="#perfundo-img1">
    <img src="img/img1_s.jpg" alt="Demo image">
  </a>
  <div id="perfundo-img1" class="perfundo__overlay fadeIn">
    <figure class="perfundo__content perfundo__figure">
      <img src="img/img1_s.jpg" alt="Demo image">
      <div class="perfundo__image" style="width: 800px; padding-top: 66.25%; background-image: url(img/img1.jpg);"></div>
    </figure>
    <a href="#perfundo-untarget" class="perfundo__close perfundo__control">Close</a>
    <a class="perfundo__next perfundo__control" href="#perfundo-img2">Next</a>
  </div>
</div>

<div class="perfundo">
  <a class="perfundo__link" href="#perfundo-img2">
    <img src="img/img2_s.jpg" alt="Demo image">
  </a>
  <div id="perfundo-img2" class="perfundo__overlay fadeIn">
    <figure class="perfundo__content perfundo__figure">
      <img src="img/img2_s.jpg" alt="Demo image">
      <div class="perfundo__image" style="width: 800px; padding-top: 66.25%; background-image: url(img/img2.jpg);"></div>
    </figure>
    <a href="#perfundo-untarget" class="perfundo__close perfundo__control">Close</a>
    <a class="perfundo__next perfundo__control" href="#perfundo-img3">Next</a>
    <a class="perfundo__prev perfundo__control" href="#perfundo-img1">Prev</a>
  </div>
</div>

<div class="perfundo">
  <a class="perfundo__link" href="#perfundo-img3">
    <img src="img/img3_s.jpg" alt="Demo image">
  </a>
  <div id="perfundo-img3" class="perfundo__overlay fadeIn">
    <figure class="perfundo__content perfundo__figure">
      <img src="img/img3_s.jpg" alt="Demo image">
      <div class="perfundo__image" style="width: 800px; padding-top: 66.25%; background-image: url(img/img3.jpg);"></div>
    </figure>
    <a href="#perfundo-untarget" class="perfundo__close perfundo__control">Close</a>
    <a class="perfundo__prev perfundo__control" href="#perfundo-img2">Prev</a>
  </div>
</div>
// No JavaScript!

Content

Open the lightbox...
Lorem Ipsum

Sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur.

Close
<div class="perfundo">
  <a class="perfundo__link" href="#perfundo-content">
    Open the lightbox...
  </a>
  <div id="perfundo-content" class="perfundo__overlay bounceIn">
    <div class="perfundo__content perfundo__html">
      <h5>Lorem Ipsum</h5>
      <p>Sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
      <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur.</p>
    </div>
    <a href="#perfundo-untarget" class="perfundo__close perfundo__control">Close</a>
  </div>
</div>
// No JavaScript!

Direct linking

perfundo.oberlehner.net/#perfundo-single

<p><a href="https://perfundo.oberlehner.net/#perfundo-single">perfundo.oberlehner.net/#perfundo-single</a></p>
// No JavaScript!

JavaScript enhanced gallery

With using some JavaScript enhancements, it is possible to disable the creation of entries in the browser history (hash links) and enable swipe support for touch devices.

<div class="perfundo js-perfundo">
  <a class="perfundo__link js-perfundo-link" href="#perfundo-img1">
    <img src="img/img1_s.jpg" alt="Demo image">
  </a>
  <div id="perfundo-img1" class="perfundo__overlay fadeIn js-perfundo-overlay">
    <figure class="perfundo__content perfundo__figure">
      <img src="img/img1_s.jpg" alt="Demo image">
      <div class="perfundo__image" style="width: 800px; padding-top: 66.25%; background-image: url(img/img1.jpg);"></div>
    </figure>
    <a href="#perfundo-untarget" class="perfundo__close perfundo__control js-perfundo-close">Close</a>
    <a class="perfundo__next perfundo__control js-perfundo-next" href="#perfundo-img2">Next</a>
  </div>
</div>

<div class="perfundo js-perfundo">
  <a class="perfundo__link js-perfundo-link" href="#perfundo-img2">
    <img src="img/img2_s.jpg" alt="Demo image">
  </a>
  <div id="perfundo-img2" class="perfundo__overlay fadeIn js-perfundo-overlay">
    <figure class="perfundo__content perfundo__figure">
      <img src="img/img2_s.jpg" alt="Demo image">
      <div class="perfundo__image" style="width: 800px; padding-top: 66.25%; background-image: url(img/img2.jpg);"></div>
    </figure>
    <a href="#perfundo-untarget" class="perfundo__close perfundo__control js-perfundo-close">Close</a>
    <a class="perfundo__next perfundo__control js-perfundo-next" href="#perfundo-img3">Next</a>
    <a class="perfundo__prev perfundo__control js-perfundo-prev" href="#perfundo-img1">Prev</a>
  </div>
</div>

<div class="perfundo js-perfundo">
  <a class="perfundo__link js-perfundo-link" href="#perfundo-img3">
    <img src="img/img3_s.jpg" alt="Demo image">
  </a>
  <div id="perfundo-img3" class="perfundo__overlay fadeIn js-perfundo-overlay">
    <figure class="perfundo__content perfundo__figure">
      <img src="img/img3_s.jpg" alt="Demo image">
      <div class="perfundo__image" style="width: 800px; padding-top: 66.25%; background-image: url(img/img3.jpg);"></div>
    </figure>
    <a href="#perfundo-untarget" class="perfundo__close perfundo__control js-perfundo-close">Close</a>
    <a class="perfundo__prev perfundo__control js-perfundo-prev" href="#perfundo-img2">Prev</a>
  </div>
</div>
// Initialize a perfundo Lightbox.
perfundo('.perfundo', {
  disableHistory: true,
  swipe: true
});