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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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 with only CSS</h1>
    <div class="md-btn-area">
      <!-- Open the first modal window("one") -->
      <a href="#modal-one" class="md-btn">Modal 1</a>
      
      <!-- Open the second modal window("two") -->
      <a href="#modal-two" class="md-btn">Modal 2</a>
      
      <!-- Open the second modal window("three") -->
      <a href="#modal-three" class="md-btn">Modal 3</a>
    </div>
    <div>
      <img src="https://unsplash.it/650/420?random" alt="pic" width="500" class="sample-img" />
    </div>
  </div>
</div>

<!-- 
// Modal window section 
-->
<!-- First modal named "one" -->
<section id="modal-one" class="modal">
  <div class="modal-inner">
    <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>
  <a href="#" class="close"><span>close</span></a>
</section>

<!-- Second modal named "two" -->
<section id="modal-two" class="modal">
  <div class="modal-inner">
    <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>
  <a href="#" class="close"><span>close</span></a>
</section>

<!-- Third modal named "three" -->
<section id="modal-three" class="modal">
  <div class="modal-inner">
    <h2>This is the third modal window!</h2>
    <img src="https://unsplash.it/660/420?random" alt="pic" width="400" class="sample-img" />
  </div>
  <a href="#" class="close"><span>close</span></a>
</section>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Lato:300);
body{
  font-family:Lato;
  background-color: #333;
}
.container {
  position:relative;
  color: #ccc;
  text-align: center;
  padding-bottom:50px;
}
.content {
  margin: 0 auto;
}
.content a {
  color:#ccc;
  text-decoration:none;
}
.content h1 {
  font-size:30px;
  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 {
  opacity:0;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  text-shadow:0 1px 0 #333;
  color: #fff;
  text-align: center;
  font-size: 20px;
  -webkit-transition: opacity .4s linear;
  transition: opacity .4s linear;
  -webkit-transform: translate(0,100%);
  -ms-transform: translate(0,100%);
  transform: translate(0,100%);
}
/* Modal content */
.modal-inner {
  position:relative;
  margin:60px 5% 5%;
  padding:20px;
  -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:15px;
  background-color:rgba(255,255,255,.2);
  z-index:10;
}
.modal h2 {
  border-bottom:1px solid;
  padding-bottom:20px;
}


/* ****************
 * Modal close button
 * *************** */
.modal .close {
  display:block;
  position: absolute;
  top: 0;
  left 0;
  width:100%;
  height:100%;
  background-color: rgba(0,0,0,.74);
  z-index:1;
}
.modal .close span {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  background-color: rgba(255,255,255,.2);
  cursor:pointer;
}
.modal .close span {
  text-indent: -9999px;
}
.modal .close span:before,
.modal .close span:after {
  content: "";
  position: absolute;
  top: 4px;
  border: 1px solid #fff;
  height: 30px;
}
.modal .close span:before {
  left: 19px;
  -webkit-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  transform: rotate(-45deg);
}
.modal .close span:after {
  right: 19px;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
}


/* ****************
 * Append modal(target id)
 * *************** */
#modal-one:target,
#modal-two:target,
#modal-three:target {
  opacity: 1;
  -webkit-transform: translate(0,0);
  -ms-transform: translate(0,0);
  transform: translate(0,0);
}
              
            
!

JS

              
                
              
            
!
999px

Console