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

              
                <button id="boxBtn">Open Modal</button>
<br>
<h1>Basic Modal-Box</h1>
<div id="modalBox" class="modal">
  <div class="modal-box">
    <div class="modal-header">
      <span class="close">&times;</span>
      <h2>Modal Box Header Title</h2>
    </div>
    <div class="modal-body">
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      <p>Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
    </div>
    <div class="modal-footer">
      <h3>Modal Box Footer Text</h3>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  background-image: url("https://lh3.googleusercontent.com/gu9RrBAzvqFYo3S1jh8RPARLQhWHsc6IpQKhceCQJwLKwWWqfvSRzFyfXAuZdE8YahFDHP76u9ukuNQpsRDk6tMQ0iRZMU8FTEYBYt3q8RdtOZFpprchhco7llH23yOS4s5XSQ9Feg=w2400");
}
#boxBtn {
  float: right;
  padding: 5px 10px;
  background-color: #00f;
  color: #fff;
  font-weight: 700;
  border: 0;
  outline: 0;
  border-radius: 6px;
  cursor: pointer;
}
h1 {
  color: #ccf;
  text-shadow: 0 0 2px #00f, 2px 2px #00f;
  text-align: center;
}
.modal {
  display: none;
  position: fixed;
  z-index: 1;
  padding-top: 100px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto; 
  background-color: rgba(155, 0, 155, 0.4);
}
.modal-box {
  position: relative;
  background-color: #fefefe;
  margin: auto;
  padding: 0;
  border: 1px solid #888;
  width: 40%;
  border-radius: 21px;
  box-shadow: 0 4px 8px 0 rgba(155, 0, 155, 0.2),
    0 6px 20px 0 rgba(155, 0, 155, 0.19);
  -webkit-animation-name: animatetop;
  -webkit-animation-duration: 0.4s;
  animation-name: animatebox;
  animation-duration: 0.4s;
}

@keyframes animatebox {
  from {
    top: -300px;
    opacity: 0;
  }
  to {
    top: 0;
    opacity: 1;
  }
}
@media screen and (max-width: 600px) {
  .modal-box {
    width: 90%;
  }
}
.close {
  color: white;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}

.modal-header {
  padding: 2px 16px;
  background-color: #00f;
  color: white;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}

.modal-body {
  padding: 2px 16px;
}

.modal-footer {
  padding: 2px 16px;
  background-color: #00f;
  color: white;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
}

              
            
!

JS

              
                var modal = document.getElementById("modalBox");
var btn = document.getElementById("boxBtn");
var span = document.getElementsByClassName("close")[0];
btn.onclick = function () {
  modal.style.display = "block";
};
span.onclick = function () {
  modal.style.display = "none";
};

window.onclick = function (event) {
  if (event.target == modal) {
    modal.style.display = "none";
  }
};

              
            
!
999px

Console