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 class="modal-open btn" href="#modal1">動画1</a>
<a class="modal-open btn" href="#modal2">動画2</a>
<a class="modal-open btn" href="#modal3">動画3</a>
<a class="modal-open btn" href="#modal4">動画4</a>

<div id="modal1" class="youtube-box modal"><div id="player1" class="youtube" data-video-id="DeJY5d14qKs"></div></div>
<div id="modal2" class="youtube-box modal"><div id="player2" class="youtube" data-video-id="HzUDAaYMNsA"></div></div>
<div id="modal3" class="youtube-box modal"><div id="player3" class="youtube" data-video-id="Cn1R92bInnc"></div></div>
<div id="modal4" class="youtube-box modal"><div id="player4" class="youtube" data-video-id="WNarpiGz3Kk"></div></div>
              
            
!

CSS

              
                .modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  z-index: 1;
  padding: 20px;
  box-sizing: border-box;
  background-color: rgb(0, 0, 0);
  background-color: rgba(0, 0, 0, 0.75);
  text-align: center;
}
.modal-content {
  display: none;
  box-sizing: border-box;
  background: #fff;
  left: 50%;
  padding: 0;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}
.modal{
  display: none;
}
iframe.youtube{;
  vertical-align: top;
}
/* スマホ設定 */
@media screen and (max-width: 768px) {
  .modal-content {
    box-sizing: border-box;
    width: 100%;
  }
  .youtube-box{
    position: relative;
    width: 100%;
    padding-top: 56.05%;
  }
  .youtube{
    width: 100%;
    position: absolute;
    height: 100%;
    top: 0;
    right: 0;
  }
}

/* 装飾 */
body {
  margin: 40px auto;
  padding: 40px 0;
  text-align: center;
  background-color: #edf1fa;
}
.btn{
  text-decoration: none;
  color: #333;
  font-weight: bold;
  background: #FFF;
  padding: 15px 20px;
  border-radius: 6px;
}
              
            
!

JS

              
                $(".modal-open").click(function() {
  modal.open($(this));
});



/*
 *  モーダル設定
 */
function Modal(el) {
  this.option = {
    modalOverlayClass: "modal-overlay",
    modalContentClass: "modal-content",
  }
}
Modal.prototype = {
  open: function (el) {
    modalObj = this; 
    targetID = el.attr('href'); 
    $target = $(targetID).clone();
    
    //モーダル表示
    $("body").append('<div class="'+this.option.modalOverlayClass+'"></div>');
    $('.'+this.option.modalOverlayClass).append('<div class="'+this.option.modalContentClass+'"></div>').fadeIn(300);
    $('.'+this.option.modalContentClass).append($target).fadeIn(300);
    $target.fadeIn();
    
    //閉じるイベント追加
    $(".modal-overlay").click(function (e) {
      modalObj.close();
    });
  },
  close: function () {
    $(".modal-overlay").remove();
    $(".modal-content").remove();
  }
};
var modal = new Modal();



/*
 *  Youtube設定
 */
var videoWidth  = '640';  //動画横サイズ
var videoHeight = '360';  //動画縦サイズ

// iframe Player APIを非同期で読み込み
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// #player にiframeplayerを作成
var player;
function onYouTubeIframeAPIReady() {
  $('.youtube').each(function(index){
    
    var videoId = $(this).data('video-id');
    var playerId = $(this).attr('id');
    
    player = new YT.Player(playerId, {
      height: videoHeight,
      width: videoWidth,
      videoId: videoId,
    });
  });
}
              
            
!
999px

Console