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">
  <div class="content">
    <h1>Simple Modal Window</h1>
    <div class="md-btn-area">
      <!-- Open the first modal window("one") -->
      <span class="md-btn one">Modal 1</span>
      
      <!-- Open the second modal window("two") -->
      <span class="md-btn two">Modal 2</span>
      
      <!-- Open the second modal window("three") -->
      <span class="md-btn three">Modal 3</span>
    </div>
    <div>
      <img src="https://unsplash.it/580/300" alt="pic" class="sample-img" />
    </div>
  </div>
</div>

<!-- 
// Modal window section 
-->
<section class="modal-area">
  <!-- First modal named "one" -->
  <div class="modal one">
    <h2>This is the first modal window!</h2>
    <p>Fusce cursus nec sem ut porttitor. Morbi imperdiet erat magna, et sollicitudin nibh iaculis ac. Donec pulvinar eros in eleifend pulvinar.</p>
    <div class="close"><span>close</span></div>
  </div>
  
  <!-- Second modal named "two" -->
  <div class="modal two">
    <h2>This is the second modal window!</h2>
    <p>Fusce cursus nec sem ut porttitor. Morbi imperdiet erat magna, et sollicitudin nibh iaculis ac. Donec pulvinar eros in eleifend pulvinar.</p>
    <div class="close"><span>close</span></div>
  </div>
  
  <!-- Third modal named "three" -->
  <div class="modal three">
    <h2>This is the third modal window!</h2>
    <img src="//placeimg.com/400/240/people" alt="pic" class="sample-img" />
    <div class="close"><span>close</span></div>
  </div>
</section>
              
            
!

CSS

              
                body{
  font-family:Lato;
  background-color: #333;
}
.container {
  color: #ccc;
  text-align: center;
  padding-bottom:50px;
}
.content {
  margin: 0 auto;
}
.content h1 {
  font-size:35px;
  margin-bottom:40px;
}
.sample-img {
  border:5px solid rgba(255,255,255,0.2);
}


/* ****************
 * Open modal button (trigger)
 * *************** */
.md-btn-area {
  margin-bottom:50px;
}
.md-btn {
  border: 1px solid #7a7a7a;
  padding: 10px;
  margin: 5px;
  border-radius: 3px;
  cursor: pointer;
  background-color: #666;
  text-shadow: 0 -1px 0 #000;
  -webkit-box-shadow: 0 0 0 1px #222;
  box-shadow: 0 0 0 1px #222;
}
.md-btn:hover {
  background-color: #6e6e6e; 
}

/* ****************
 * Modal window
 * *************** */
.modal {
  display: none;
  position: fixed;
  top: 3%;
  left: 3%;
  width: 94%;
  height: 94%;
  overflow-y: auto;
  padding: 60px 5% 5%;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-box-shadow: 0 0 15px rgba(0,0,0,0.2);
  box-shadow: 0 0 15px rgba(0,0,0,0.2);
  border-radius: 30px;
  background-color: rgba(29, 48, 68, 0.53);
  text-shadow:0 1px 0 #333;
  color: #fff;
  text-align: center;
  font-size: 20px;
}
.modal h2 {
  border-bottom:1px solid;
  padding-bottom:20px;
}

/* Second modal window */
.modal.two {
  color:lightblue;
}

/* Close button */
.modal .close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background-color: rgba(255,255,255,.2);
  cursor:pointer;
}
.modal .close:before,
.modal .close:after{
  position:absolute;
  top:4px;
  border:1px solid #fff;
  height:30px;
  content:"";
}
.modal .close:before {
  left:19px;
  -webkit-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  transform: rotate(-45deg);
}
.modal .close:after {
  right:19px;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
}
.modal .close span {
  display:none;
}

/* ****************
 * Background filter (blur)
 * *************** */
.bg-blur {
  filter: blur(10px);
  -webkit-filter: blur(10px);
  -moz-filter: blur(10px);
  -o-filter: blur(10px);
  -ms-filter: blur(10px);
  filter: url(#blur);
  filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius='10');
  -webkit-transition: all .4s linear;
  transition: all .4s linear;
}
              
            
!

JS

              
                $(function(){
  var target = '';
  $(".md-btn").click(function(){
    // Get the second class of "btn" class
    target = $(this).get(0).className.split(" ")[1];
    // Set the target modal window
    target = $(".modal." + target);
    // Show modal window
    if ( target.is(":hidden") ) {
      target.fadeIn(600);
      $(".container").addClass("bg-blur");
    } else {
      target.hide();
      $(".container").removeClass("bg-blur");
    }
  });
  
  // Hide modal window
  $(".close, .modal").click(function(){
    $(".modal").hide();
    $(".container").removeClass("bg-blur");
  });
});
              
            
!
999px

Console