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

              
                <div class="container">
  <h1>Flexbox Modals</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Non cumque expedita officiis ea dolores magnam, ab quasi. Iusto aut illum culpa, ex cupiditate veritatis est adipisci earum obcaecati inventore beatae.</p>
  <button class="btn btn-modal">Click Here</button>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda facere ipsum aperiam minus cupiditate id itaque, eos cum non officia? Obcaecati repudiandae, quod magnam esse, dignissimos officiis veritatis odit tempora!</p>
  <p>Totam suscipit, esse qui, veritatis rem autem? Quae excepturi magni itaque, ipsa laboriosam consequatur ipsam! Sunt nulla voluptatibus commodi velit, impedit consectetur distinctio quisquam. Quia dolores ex nesciunt, repellendus animi.</p>
  <p>Tempora quam ut, adipisci iste rerum alias maxime minus! Veritatis quas labore est eius ipsa, autem asperiores ullam. Aut veniam magnam mollitia culpa totam, eaque hic enim, ut et voluptatem.</p>
</div>

<div class="modal-container">
  <div class="modal">
    <h2>Modal Heading</h2>
    <div class="modal-body">
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem placeat, itaque! Dolores vel sequi, unde alias, ab quisquam ullam deserunt molestiae tempora quo esse fugiat fugit, facere tenetur quasi voluptas?</p>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  margin: 0;
  font-family: Helvetica, sans-serif;
}
.container {
  width: 600px;
  margin: 0 auto;
}

.btn {
  width: 100%;
  border: none;
  padding: 10px;
  background-color: #35a;
  color: #fff;
  cursor: pointer;
}

.modal-container {
  position: absolute;
  background-color: rgba(0,0,0,.5);
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  width: 400px;
  height: 200px;
  background-color: #eee;
  font-size: 14px;
  border-radius: 8px;
  box-shadow: 0 0 40px #555;
}

.modal h2 {
  background-color: #40a9ed;
  color: #fff;
  padding: 10px;
}

.modal-body { padding: 10px; padding-top: 0; }
              
            
!

JS

              
                $(".modal-container").hide();
$(".btn-modal").on("click", function() {
  $(".modal-container").fadeIn(500);
  $(".modal-container").on("click", function() {
    $(this).fadeOut(500);
  });
});
              
            
!
999px

Console