Pen Settings



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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


                <div class="container">
    <h1>David's house of stuff</h1>
    <button class="profile-button">Profile</button>
    <h2 class="product-list-title">Stuff you can buy</h2>
    <ul class="product-list">
      <li class="product-list-item">Velcro shoes</li>
      <li class="product-list-item product-list-item--special">Male fish (special!)</li>
      <li class="product-list-item">Corned beef (sandwich not included)</li>
      <li class="product-list-item">Fake teeth fossils</li>
      <li class="product-list-item">Fifth product</li>
  <ul class="profile-menu" hidden>
    <li class="profile-menu-item">Sign in</li>
    <li class="profile-menu-item">Sign out</li>
    <li class="profile-menu-item">Sign up</li>
    <li class="profile-menu-item">Sign on</li>
    <li class="profile-menu-item">Sign away</li>
  <div class="modal">
    You are about to be signed out because of inactivity. Do anything to continue your session.


                $z-index-header: 1;
$z-index-side-nav: 2;
$z-index-drop-down-menu: 3;
$z-index-full-screen-modal: 4;

@mixin new-stacking-context {
  position: relative;
  z-index: 0;

@mixin shadow {
  box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);

body {
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
  color: #222;
  background: snow;

* {
  box-sizing: border-box;

li {
  margin: 0;
  padding: 0;
  font-weight: 400;

li {
  list-style-type: none;

.container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  border: 1px solid lightgrey;

header {
  position: relative;
  display: flex;
  align-items: center;
  padding: 10px;
  background: seagreen;
  color: mintcream;
  @include shadow;
  z-index: $z-index-header;

main {
  background: white;

.profile-button {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  font-size: inherit;
  text-decoration: underline;
  padding: 10px;

.profile-menu {
  position: absolute;
  top: 50px;
  right: 15px;
  width: 150px;
  background: white;
  @include shadow;
  z-index: $z-index-drop-down-menu;
  &:before {
    content: "▲";
    color: white;
    position: absolute;
    top: -17px;
    right: 10px;
    font-size: 20px;

.profile-menu-item {
  padding: 10px 20px;
  &:not(:first-child) {
    border-top: 1px solid lightgrey;

.product-list {
  @include new-stacking-context;

.product-list-title {
  padding: 50px 20px 20px;

.product-list-item {
  padding: 20px;
  border-top: 1px solid lightgrey;
  position: relative;
  &--special {
    background: honeydew;
  &:hover {
    @include shadow;
    z-index: 1; // this could be 9999999 and it wouldn't matter. It's contained within .product-list

.modal {
  display: none; // comment out for testing
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 30px;
  padding: 50px;
  text-align: center;
  pointer-events: none; // so you can click the profile button while this is 'open'
  z-index: $z-index-full-screen-modal;


                const profileButtonEl = document.querySelector('.profile-button');
const profileMenuEl = document.querySelector('.profile-menu');

profileButtonEl.addEventListener('click', () => {
  profileMenuEl.hidden = !profileMenuEl.hidden;