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

              
                <div class="fit">
  <video src="https://125naroom.com/demo/video/itukanokoto_b.mp4" class="fitsize" preload="metadata" playsinline autoplay loop muted><p>動画を再生するにはvideoタグをサポートしたブラウザが必要です。</p></video>
  <h1>【jQuery】動画を全画面表示にして中央に表示する、スマホでも崩れない | 125naroom</h1>
</div>

<section>
  <p class="_a"><a href="https://125naroom.com/web/3857" target="_blank" class="link">詳しくはこちら</a></p>
</section>
              
            
!

CSS

              
                /*=========
.fit
=========*/

.fit {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fitsize {
  position: absolute;
}

/*=========
base
=========*/

html, body {
  margin: 0;
  padding: 0;
}
body {
  font-family: YuGothic, "游ゴシック体", "Yu Gothic", "ヒラギノ角ゴ Pro", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, "MS Pゴシック", "MS PGothic", sans-serif;
  letter-spacing: .025em;
  line-height: 1.8;
}
* {
  box-sizing: border-box;
}
section {
  background: #fff;
  padding: 10em 0;
}
h1 {
  font-size: 22px;
  line-height: 2.0;
  padding: 1em .5em;
  margin: 0;
  position: relative;
  border-top: 4px solid #f2f2f2;
  border-bottom: 4px solid #f2f2f2;
  text-align: center;
}
h1:after {
  content: "";
  display: block;
  position: absolute;
  background-color: #fff689;
  width: 20%;
  height: 4px;
  bottom: -4px;
  left: 0;
  right: 0;
  margin: 0 auto;
}
._a {
  max-width: 300px;
  margin: 0 auto;  
}
._a a {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 2.0em 1.0em;
  border: 1px solid #222222;
  background: linear-gradient(to right, #ffffff 50%, #222222 50%);
  background-size: 200% auto;
  color: #222222;
  font-size: 14px;
  text-decoration: none;
  text-align: center;
  transition: .3s;
  position: relative;
}
._a a:after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 100%;
  height: 100%;
  border-right: 1px solid #222222;
  border-bottom: 1px solid #222222;
}
._a a:hover {
  color: #ffffff;
  background-position: -100% 0;
}
              
            
!

JS

              
                jQuery(function($){
  var winH = $(window).height();
  //全画面表示の場所を指定する
  $('.fit').outerHeight(winH);

  $(window).on('load',function(){
    //画像、動画のクラスを決める
    setBgImg($('.fitsize'));
  });

  $(window).on('resize',function(){
    //リサイズ指定
    winH = $(window).height();
    $('.fit').outerHeight(winH);

    setBgImg($('.fitsize'));
  });

  function setBgImg(object){
    //画像サイズ取得
    var imgW = object.width();
    var imgH = object.height();

    //ウィンドウサイズ取得
    var winW = $(window).width();
    var winH = $(window).height();	

    //幅・高さの拡大・縮小率取得
    var scaleW = winW / imgW;
    var scaleH = winH / imgH;

    //幅・高さの拡大・縮小率の大きいものを取得
    var fixScale = Math.max(scaleW, scaleH);

    //画像の幅高さを設定
    var setW = imgW * fixScale;
    var setH = imgH * fixScale;

    //画像の位置を設定
    var moveX = Math.floor((winW - setW) / 2);
    var moveY = Math.floor((winH - setH) / 2);

    //設定した数値でスタイルを適用
    object.css({
      'width': setW,
      'height': setH,
      'left' : moveX,
      'top' : moveY
    });
  }
});
              
            
!
999px

Console