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.

            
              <div class="trigger" id="js-trigger" @click="execute">
  <p>Click to open the modal</p>
</div>
<div id="js-modal">
  <div class="modal" v-show="opened" @click.self="close">
    <div class="modal__close" @click="close">×</div>
    <div class="modal__content">
      <!-- カスタムディレクティブv-playingを利用し、videoタグに対して -->
      <!-- モーダルインスタンスのopenedデータ変更と連動して処理を実行 -->
      <video
        src="https://goo.gl/qHXCm4" controls
        width="300" height="168"
        v-playing="opened"
      ></video>
    </div>
  </div>
</div>
            
          
!
            
              html, body, .trigger {
  margin: 0;
  width: 100%; height: 100%;
  position: relative;
}

.trigger > p {
  margin: 0;
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font: bold 40px/1 sans-serif;
  opacity: .1;
  width: 600px;
}

.modal {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 10;
  background: rgba(0, 0, 0, .7);
  transform: translate3d(0, 0, 0);
}

.modal__close {
  position: absolute; top: 4px; right: 16px;
  color: #fff;
  cursor: pointer;
  font: bold 40px/1 sans-serif;
}
.modal__content {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.modal__content > * {
  display: block;
  position: relative;
}


            
          
!
            
              var bus = new Vue();

// v-playingという名前のカスタムディレクティブを定義
Vue.directive('playing', function(el, binding) {
  // ディレクティブの値に応じて要素のplay/pauseメソッドを実行する
  el[binding.value ? 'play' : 'pause']();
});

new Vue({
  el: '#js-trigger',
  methods: {
    execute: function() {
      bus.$emit('click.trigger');
    }
  }
});

new Vue({
  el: '#js-modal',
  data: {
    opened: false
  },
  methods: {
    open: function() {
      this.opened = true;
    },
    close: function() {
      this.opened = false;
    }
  },
  created: function() {
    bus.$on('click.trigger', this.open);
  }
});
            
          
!
999px
Loading ..................

Console