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

              
                <!-- クリックしてモーダルを表示させるボタン -->
<a href="#" class="btn">モーダルウィンドウを表示</a>

<!-- オーバーレイ(黒い背景) -->
<div class="overlay"></div>

<!-- モーダルウィンドウ -->
<div class="modal">
  <!-- モーダルウィンドウを閉じる×ボタン -->
  <div class="close">&times</div>
    <h2>モダルのタイトル</h2>
    <p>ここにモダルの内容が入ります。ここにモダルの内容が入ります。ここにモダルの内容が入ります。ここにモダルの内容が入ります。ここにモダルの内容が入ります。ここにモダルの内容が入ります。</p>
</div>

<!-- 高さを出すためのsectionタグ -->
<section></section>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap');

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

body {
  font-family: 'Noto Sans JP', sans-serif;
}

/* クリックしてモーダルウィンドウを表示するボタン */
.btn {
  display: inline-block;
  text-decoration: none;
  padding: 10px 20px;
  background: linear-gradient(to right bottom, #48D1CC, #008B8B);
  border-radius: 5px;
  color: #fff;
  margin: 20px;
  transition: 0.3s;
}

.btn:hover {
  opacity: 0.8;
}

/* オーバーレイ */
.overlay {
  /* 位置を固定 */
  position: fixed;
  top: 0;
  left: 0;
  /* 画面いっぱいに広がるようにする */
  width: 100%;
  height: 100vh;
  /* 黒い背景色(今回は黒で60%の不透明度) */
  background: rgba(0, 0, 0, 0.6);
  /* デフォルトでは非表示にしておく */
  display: none;
}

/* モーダルウィンドウ */
.modal {
  /* 大きさを指定 */
  max-width: 500px;
  width: 86%;
  /* 見た目を整える */
  padding: 15px 20px;
  background: #fff;
  /* 位置を固定表示 */
  position: fixed;
  /* 画面の真ん中に表示されるように指定 */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* デフォルトでは非表示にしておく */
  display: none;
}

/* モーダルウィンドウ内にある×ボタン */
.modal .close {
  /* モーダルウィンドウを基準に位置を調整 */
  position: absolute;
  top: 10px;
  right: 20px;
  /* ホバーしたらカーソルの形になるようにする */
  cursor: pointer;
  font-size: 20px;
}

/* モーダルウィンドウ内の見出しのスタイル調整 */
.modal h2 {
  font-size: 18px;
  font-weight: normal;
  margin-bottom: 10px;
}

/* モーダルウィンドウ内の文章の文字サイズの調整 */
.modal p {
  font-size: 13px;
}

/* スクロールできるように高さを出すためのsectionタグ */
section {
  height: 200vh;
}

              
            
!

JS

              
                $(document).ready(function(){ 
  // ボタンをクリックしたら
  $(".btn").click(function () {
    // モーダルウィンドウとオーバーレイをフェードインさせる
    $(".modal").fadeIn();
    $(".overlay").fadeIn();
  });

  // モーダルウィンドウ内の×ボタンかオーバーレイをクリックしたら
  $(".close, .overlay").click(function () {
    // モーダルウィンドウとオーバーレイをフェードアウトさせる
    $(".modal").fadeOut();
    $(".overlay").fadeOut();
   });
});
              
            
!
999px

Console