Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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

              
                <p>Following is a number of images laid out in a grid, clickiing on an image or pressing enter when it has keyboard focus opens the image in a full screen view.</p>
<main class="grid">
  <span role="button" class="fullscreenEnabled">
    <img     src="https://assets.codepen.io/1281712/little-nemo-19051126-l.jpeg" alt="Little Nemo ThanksGiving Day Dream">
  </span>
  <span role="button" class="fullscreenEnabled">
  <img  src="https://assets.codepen.io/1281712/little-nemo-19051022-l.jpeg" alt="Little Nemo Mushroom forest">
    </span>
  <span role="button" class="fullscreenEnabled">
  <img  src="https://assets.codepen.io/1281712/little-nemo-19051029-l.jpeg" alt="Little Nemo wal,s on stilts and gets assaulted by storks">
    </span>
  <span role="button" class="fullscreenEnabled">
  <img        src="https://assets.codepen.io/1281712/little-nemo-19051105-l.jpeg" alt="Water floods Little Nemo's bedroom and he goes under the sea">
    </span>
  <span role="button" class="fullscreenEnabled">
  <img   src="https://assets.codepen.io/1281712/little-nemo-19051112-l.jpeg" alt="Fairy helps Nemo to get to slumberland but she turns him into a monkey on the way">
    </span>
  <span role="button" class="fullscreenEnabled">
  <img           src="https://assets.codepen.io/1281712/little-nemo-19051119-l.jpeg" alt="Fuzo and Queen Crystalette attempt to bring Little Nemo to Slumberland">
    </span>
</main>
              
            
!

CSS

              
                .grid { 
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-gap: 20px;
  align-items: stretch;
  }

.grid img {
  border: 1px solid #ccc;
  max-width: 100%;
}

span:fullscreen {
  overflow: auto;
}

span::backdrop {
  visibility: hidden;
} 

span:fullscreen img {
  object-fit: contain;
  border: 0;
}
              
            
!

JS

              
                const makeFullScreen = (el) => {
   if (!document.fullscreenElement) {
     el.requestFullscreen();
     return;
  } 
    document.exitFullscreen();
 
}

const  fullscreenables = document.querySelectorAll(".fullscreenEnabled");
fullscreenables.forEach( (span) => {
span.addEventListener("click", () => {
 makeFullScreen(span);
});
span.addEventListener('keydown', (e) => {
  if (e.key === "Enter") {
    makeFullScreen(span);
  }
});

});
              
            
!
999px

Console