hide_kichiの情報

気になる情報を適当にアップしていきます

【HTML】Chrome で背景に動画(MP4)を表示

f:id:hide_kichi:20191202143845j:plain

WEB上の背景に動画を表示する場合です。

1.HTML

 <!-- 動画背景 -->
   <div class="wrap">
   <link rel="stylesheet" type="text/css" href="bbb.css">
    <!-- 背景用の動画ファイル -->
    <video id="bg-video" src="video/home-top.mp4" poster="" width=100  height=50  right=400 bottom=10 autoplay loop muted></video>
   <!-- 背景の上に表示させたいコンテンツ -->
    <div class="header-title">
    <p>
       TEST  SAFETY!!
    </p>
    </div>
   </div>

 

<video id="bg-video" src="video/home-top.mp4" poster="" width=100  height=50 
 right=400 bottom=10 autoplay loop muted></video>
 

 

・mp4のTYPEは「h264/AVC」にします。

・muted を追加します。

・動画の大きさ width=100  height=50 で指示します。

・動画の位置  right=400 bottom=10 で指示します。

 

BBS.CCSファイルの内容

CCSファイルの最後の行に追加します。

/* ----- 背景用 ----- */
#bg-video{
 positionfixed;
 right:  400;
 bottom20;
 min-width50%;
 min-height50%;
 width480;
 height400;
 z-index-100;
 backgroundurl('poster.jpg'no-repeat;
 background-sizecover;
}
/* ----- 背景の上に表示 ---- */
.header-title{
 positionrelative/*必要*/
 z-index2/*必要*/
 displayflex;
 width50%;
 justify-contentcenter;
 align-itemscenter;
 text-align:center;
 marginauto;
}

以上