123

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. 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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1>
  CSS Injection
  <span>
    Now on CodePen!
  </span>
</h1>

<p>Try this:</p>

<ol>
  <li>Open a modal: <button class="modal-button">Open Modal</button></li>
  <li>Change the modal style in the CSS</li>
  <li>Notice the modal stays open!</li>
</ol>

<p>The page doesn't refresh entirely when making only CSS changes. Only when changing HTML or JS. That means the state of the page is maintained (a full refresh would have closed the modal. Also, FASTER!</p>

<div id="modal">
<div class="modal">
  <h3>I'm a modal. Go ahead and style me.</h3>
  <p>I won't up and close on you.</p>
  <button class="modal-button">Close Modal</button>
</div>
<div id="overlay"></div>
</div>
            
          
!
            
              // 
// TRY STYLING ME
// (when the modal is open)
//

.modal {
  background: white;
  border: 5px solid #f06d06;
  box-shadow: 0 0 50px rgba(black, 0.5);
  padding: 30px 80px;
  
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5000;
}
#overlay {
  content ""
  position: absolute;
  top 0
  left 0
  right 0
  bottom 0
  background rgba(#f06d06, 0.75)
}



body
  text-align center;
  font: 100%/1.4 Georgia
  max-width: 600px;
  padding: 10px;
  margin 0 auto

h1
  span {
    display: block;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.1rem;
    margin: 0.5rem;
  }

li
  list-style-position: inside;

#modal {
  display: none;
}
            
          
!
            
              var buttons = document.querySelectorAll(".modal-button");
var modal = document.getElementById("modal");

[].forEach.call( document.querySelectorAll('.modal-button'), function(el) {
   el.addEventListener('click', function() {
     if (modal.style.display == "block") {
       modal.style.display = "none"
     } else {
       modal.style.display = "block"
     }
  }, false);
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console