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="overlay">
  
</div>

<div class="modal">
  <h1>This is modal</h1>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Aspernatur rem ipsa deserunt modi vitae quis minima, atque autem saepe corporis!</p>
  <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nostrum tempora illum, eius, minima quo dolorem repellat assumenda error quae inventore fugiat aliquid eos culpa. Tempora vel doloribus rerum, reiciendis at natus eum labore quas tempore, exercitationem alias. Dignissimos, tenetur aut!</p>
  <button class="modal__button-close">
  </button>
</div>

<button type="button" class="modal__button-open">Open Modal</button>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=PT+Sans:400,700');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
}

body { 
  font-family: 'PT Sans', sans-serif;
  background-color: #567;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
}


.modal {
  background-color: orange;
  width: 50%;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 50px;
  box-shadow: 0px 0px 30px rgba(0,0,0,.3);
  word-wrap: break-word;
  transform-origin: center;
  transition: opacity .4s ease-out, visibility .4s, transform .4s ;
}

h1 {
  padding: 20px;
}

p {
  text-indent: 20px;
  margin-bottom: 20px;
}

.overlay {
  position: fixed;
  background-color: rgba(0,0,0,.3);
  width: 100%;
  height: 100%;
  backdrop-filter: blur(5px);
  transition: opacity .4s ease-out, visibility .4s;
}

.modal__button-close {
  background-color: transparent;
  border: none;
  color: #fff;
  padding: 10px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 5px;
  top: 5px;
  cursor: pointer;
  transition: color .2s;
}

.modal__button-close::before {
  content: '';
  display: block;
  width: 100%;
  height: 3px;
  background-color: currentColor;
  box-shadow: 0px 10px 0px currentColor, 0px -10px 0px currentColor;
}

.modal__button-close:hover,
.modal__button-close:active {
  color: rgba(255, 255, 255, .7);
}



.modal--closed,
.overlay--hidden {
  visibility: hidden;
  opacity: 0;
  z-index: -10;
}

.modal--closed {
  transform: translate(-50%, -50%) scale(.2);
}


.modal__button-open {
  border: none;
  background-color: transparent;
  text-transform: uppercase;
  font-weight: 700;
  color: #fff;
  padding: 20px;
  border-radius: 12px;
  font-size: 28px;
  cursor: pointer;
  border: 3px solid orange;
  transition: background-color .2s ease-out;
  
}
.modal__button-open:focus {
  outline: none;
}
.modal__button-open:hover,
.modal__button-open:active {
  background-color: orange;
}

              
            
!

JS

              
                const modal = document.querySelector('.modal')
const overlay = document.querySelector('.overlay')
const modalCloseButton = document.querySelector('.modal__button-close')
const modalOpenButton = document.querySelector('.modal__button-open')

function showModal() {
  modal.classList.toggle('modal--closed')
  overlay.classList.toggle('overlay--hidden')
}


modalCloseButton.addEventListener('click', showModal)
modalOpenButton.addEventListener('click', showModal)
overlay.addEventListener('click', showModal)


              
            
!
999px

Console