首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在铬上使用背景视频?

如何在铬上使用背景视频?
EN

Stack Overflow用户
提问于 2021-12-08 19:15:27
回答 1查看 96关注 0票数 -1

嘿,各位,我有个有点愚蠢的问题,显然我解决不了.我正在为一个任务开发这个网站,一切看起来都很好。但我是用狩猎旅行来设计网站的。

现在,当我打开该网站的铬,视频是不显示。我看到了一些关于如何创建背景视频的教程,但却把我所有的项目都搞砸了。我的问题是,我在CSS而不是HTML上实现了视频。在不改变所有HTML和CSS的情况下,CSS有什么简单的修复吗?

在这里我的网站,我知道它不是完美的耐心对我:D

https://bragainmax.netlify.app/index.html

HTML

代码语言:javascript
复制
.hero{
  min-height: 80vh;
  background: url("./_images/shop.mp4") center/cover no-repeat;
  display: grid;
  place-items: center;
}

.banner{
  background-color: white;
  padding: 4rem 0;
  border-radius: var(--borderRadius);
  box-shadow: var(--shadow-2);
  width: 80vw;
  text-align: center;
  max-width: var(--fixed-width);
}
代码语言:javascript
复制
<header class="hero">
   <div class="banner">
      <h1 class="title">Bargain Max</h1>
      <h1 class="title-underline"></h1>
      <p class="home_p title">The Products that you love for the price that you need</p>
      <button type="button" class="btn"> <a href="product.html">Our Products</a> </button>
   </div>
</header>

EN

回答 1

Stack Overflow用户

发布于 2021-12-11 20:02:31

Υou不能以这种方式导入背景视频,您必须这样做。

希望我帮了你。

代码语言:javascript
复制
  .video-bg {
     object-fit: cover;
     height: 100%;
     width: 100%;
    }

    video {
     height: 100%;
     width: 100%;
     object-fit: cover;
    }

   .hero {
     min-height: 80vh;
     background: url("./_images/shop.mp4") center/cover no-repeat;
     display: grid;
     place-items: center;
   }

  .banner{
    background-color: white;
    padding: 4rem 0;
    border-radius: var(--borderRadius);
    box-shadow: var(--shadow-2);
    width: 80vw;
    text-align: center;
    max-width: var(--fixed-width);
    position: absolute;
   }
代码语言:javascript
复制
 <header class="hero">
    
    <div class="video-bg">

       <video preload="metadata" id="header-background-video" autoplay="" muted="" loop="" class="video"><source src="/_images/shop.mp4" type="video/mp4">
       </video>         
         
    </div>
   <div class="banner">
     <h1 class="title">Bargain Max</h1>
     <h1 class="title-underline"></h1>
     <p class="home_p title">The Products that you love for the price that you need</p>
     <button type="button" class="btn"> <a href="product.html">Our Products</a> </button>
   </div>
 </header>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70280527

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档