Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
  <h1>Parvus</h1>
  <p>Overlays suck, but if you need one, you might consider using Parvus. Parvus is an open source, dependency free image lightbox with the goal of being accessible.</p>
</div>

<div class="container">
  <h2>Gallery</h2>
  <p>Gallery with the <code>data-group</code> attribute.</p>
  <div class="flex padding-top-m">
    <div class="flex__md-4">
      <a href="https://rqrauhvmra.com/parvus/images/2-1200.webp" class="lightbox" data-group="Netherlands">
        <img src="https://rqrauhvmra.com/parvus/images/2-370.webp" alt="Picturesque house facades in Leiden, a city and municipality in the province of South Holland, Netherlands." width="370" height="657">
      </a>
    </div>

    <div class="flex__md-4">
      <a href="https://rqrauhvmra.com/parvus/images/3-1200.webp" class="lightbox" data-group="Netherlands" data-caption="A day trip to Leiden on our vacation in the Netherlands.">
        <img src="https://rqrauhvmra.com/parvus/images/3-370.webp" alt="The river 'Oude Rijn' in Leyden, a city and municipality in the province of South Holland, Netherlands." loading="lazy" width="370" height="208">
      </a>
    </div>

    <div class="flex__md-4">
      <a href="https://rqrauhvmra.com/parvus/images/1-1200.webp" class="lightbox-new" data-group="Netherlands" data-srcset="https://rqrauhvmra.com/parvus/images/1-1200.webp 1200w, https://rqrauhvmra.com/parvus/images/1-1000.webp 1000w, https://rqrauhvmra.com/parvus/images/1-700.webp 700w, https://rqrauhvmra.com/parvus/images/1-500.webp 500w">
        <img src="https://rqrauhvmra.com/parvus/images/1-370.webp" alt="Picturesque house facades in Leyden, a city and municipality in the province of South Holland, Netherlands." loading="lazy" width="370" height="208">
      </a>
    </div>
  </div>
</div>

<div class="container">
  <h2>Gallery</h2>
  <p>Gallery with the <code>gallerySelector</code> option.</p>
  <div class="flex gallery padding-top-m">
    <div class="flex__md-4">
      <a href="https://rqrauhvmra.com/parvus/images/8-1200.webp" class="lightbox">
        <img src="https://rqrauhvmra.com/parvus/images/8-370.webp" alt="" loading="lazy" width="370" height="277">
      </a>
    </div>

    <div class="flex__md-4">
      <a href="https://rqrauhvmra.com/parvus/images/9-1200.webp" class="lightbox">
        <img src="https://rqrauhvmra.com/parvus/images/9-370.webp" alt="" loading="lazy" width="370" height="277">
      </a>
    </div>
  </div>
</div>

<div class="container">
  <h2>Non-grouped images</h2>
  <div class="flex">
    <div class="flex__md-4">
      <a href="https://rqrauhvmra.com/parvus/images/4-1200.webp" class="lightbox">
        <img src="https://rqrauhvmra.com/parvus/images/4-370.webp" alt="2 glasses filled with Mojito Cocktail on a dark table." loading="lazy" width="370" height="657">
      </a>
    </div>
  </div>
</div>

<div class="event" hidden></div>
              
            
!

CSS

              
                /**
 * Set custom Parvus styles
 *
 */
.parvus {
  --parvus-background-color: hsl(23deg 40% 96%);
}

.parvus__overlay {
  opacity: 0.94;
}

/**
 * Only for demo
 *
 */
* {
  margin: 0;
  padding: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font: normal normal 400 100%/1.65 -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

body {
  background-color: #fff;
  color: #404040;
  padding-block: calc((24 / 16) * 1rem);
}

.container {



  & + & {
    margin-block-start: calc((24 / 16) * 1rem);
  }
}

.padding-top-m {
  padding-block-start: calc((16 / 16) * 1rem);
}

h1 {
  margin-block-end: calc((16 / 16) * 1rem);
}

h2 {
  margin-block-end: calc((16 / 16) * 1rem);
}

p {
  max-inline-size: 67ch;
}

img {
  block-size: auto;
  display: block;
  inline-size: 100%;
  max-inline-size: 100%;
}

code {
  background-color: #f3f4f4;
  font-size: calc((16 / 16) * 1rem);
  line-height: 1.75;
  padding-block: calc((3 / 16) * 1rem);
  padding-inline: calc((6 / 16) * 1rem);
}

.event {
  background-color: #00f;
  color: #fff;
  inset-block-end: calc((16 / 16) * 1rem);
  inset-inline-start: calc((16 / 16) * 1rem);
  padding-block: calc((8 / 16) * 1rem);
  padding-inline: calc((16 / 16) * 1rem);
  position: fixed;
  z-index: 9999;
}

:focus-visible {
  outline: calc((2 / 16) * 1rem) dashed blue;
  outline-offset: calc((2 / 16) * 1rem);
}

              
            
!

JS

              
                /**
 * Parvus
 *
 * @author Benjamin de Oostfrees
 * @version 2.6.0
 * @url https://github.com/deoostfrees/parvus
 *
 * MIT license
 */
const prvs = new Parvus({
  gallerySelector: '.gallery'
})

// API
const newImage = document.querySelector('.lightbox-new')

prvs.add(newImage)

// Events
const EVENT_EL = document.querySelector('.event')

prvs.on('open', function () {
  EVENT_EL.removeAttribute('hidden');
  EVENT_EL.innerHTML = 'Opened Parvus'
})

prvs.on('select', function () {
  EVENT_EL.innerHTML = `Select slide ${prvs.currentIndex() + 1}`
})

prvs.on('close', function () {
  EVENT_EL.innerHTML = 'Closed Parvus'
  
  setTimeout(function () {
    EVENT_EL.setAttribute('hidden', true);
  }, 2000);
})

              
            
!
999px

Console