Full Screen HTML5 Video Background without JS

后端 未结 4 1150
孤街浪徒
孤街浪徒 2020-12-21 04:13

I would like to create a full-screen video background on my website, ideally using only HTML and CSS. I also need the video background to be stuck to the top of the page, so

4条回答
  •  情书的邮戳
    2020-12-21 04:35

    I believe min-width and min-height both set to 100% is the correct way to go, but all of the parent heights also have to be set to 100% in order for it to work.

    html, body, div.container-fluid, div.video-container {
      height: 100%;
      width: 100%;
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      overflow: hidden;
    }
    video, source {
      min-height: 100%;
      min-width: 100%;
    }

提交回复
热议问题