cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <h1>Play List</h1>

<div id="main-video">
  <p id="moveTitle">動画を選択してください。</p>
  <iframe width="600" height="315" ></iframe>
</div>

<ul id="list">
  <li v-for="(item,index) in items">
    <a onClick="return false;" v-on:click="movieDetail(index)" v-bind:href="item.snippet.resourceId.videoId" >
      <img v-bind:src="item.snippet.thumbnails.high.url">
      <span class="title">{{ item.snippet.title }}</span>
      <span class="des">{{ item.snippet.description }}</span>
    </a>
  </li>
</ul>
            
          
!
            
              *{
  margin:0;
  padding:0;
}

h1{
  margin: 20px;
  text-align: center;
  
}

#main-video{
  display: block;
  width: 600px;
  min-height: 315px;
  margin: 0 auto 40px;
  background: #000;
  p{
    color: #fff;
  }
}

#list{
  width: 240*3px;
  margin: 20px auto 0;
  display: flex;
  flex-wrap: wrap;
}

li{
  display: block;
  width: 27.5%;
  margin-right: 20px;
  list-style-type: none;
  padding:10px;
  background-color: #ddd;
  margin-bottom: 20px;
  border-radius: 20px;
  img {
    width: 200px;
    margin-bottom: 10px;
    border-radius: 20px;
  }
  a{
    color: #000;
    text-decoration: none;
  }
  float: left;
}

li:after{
  celer:both;
}

.title{
  font-weight: bold;
  margin-bottom: 10px;
}

.des {
  font-size: 14px;
  margin-bottom: 20px;
}

iframe{
  border: none;
}

#moveTitle {
  text-align: center;
}
            
          
!
            
              axios.get('https://www.googleapis.com/youtube/v3/playlistItems', {
    params: {
      part: 'snippet',
      playlistId: 'PLAeW7D2lL7xJ5WuGDRr_5bwsHeNFI-R5o', /*Youtubeのplaylist id*/
      maxResults: 9, /*表示する動画の数*/
      key: 'AIzaSyCgC1TYMXKTWfXbawSpoPc3agUzlokWSjQ' /*code penからのアクセスのみ許可*/
    }
  })
  .then(function (response) {
    initVue(response.data.items);
  })
  .catch(function (error) {
    console.log(error);
  });

  function initVue(moveInfo){
    var vm = new Vue({
      el: "#list",
      data: {
        items:[]
      },
      created: function(){
          for(var i = 0; i < moveInfo.length; i++){
             this.items.push(moveInfo[i]);
          }
      },
      methods: {
        movieDetail: function (index) {
          var videoId = this.items[index].snippet.resourceId.videoId;
          var title = this.items[index].snippet.title;
          
          var mainVideoElem = document.querySelector('#main-video');
          
          //削除処理
          var move = document.querySelector('iframe');
          var moveTitleElem = document.querySelector('#moveTitle');
          mainVideoElem.removeChild(move);
          
          //追加処理
          var iframe = document.createElement('iframe');
          iframe.src = 'https://www.youtube.com/embed/'+ videoId +'?rel=0';
          iframe.width = "600";
          iframe.height = "315";
          mainVideoElem.appendChild(iframe);
          moveTitleElem.innerHTML = title;
        }
      }
    });
  }
            
          
!
999px
Loading ..................

Console