html - 隐藏视频背景溢出

标签 html css

我试图将视频的溢出隐藏为与容器相同的大小,我尝试过 overflow: hidden;在容器上,但没有任何效果。

基本上,当您查看该网站时,我试图让视频不调整其宽高比,而只是隐藏容器溢出的部分。

    <header id="welcome-section">
        <div>
            <p id="hello">Hello, my name is</p>
            <h1 id="ryan">Ryan Thacker</h1>
            a href="#section-a" class="button">Learn More</a>
        </div>
        <video autoplay muted loop id="bgVideo">
           <source src="images/Beach.webm" type="video/mp4">
        </video>
    </header>
    #welcome-section {
      background-size: cover;
      background-position: center;
      height: 100vh;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      padding: 0 20px;
      text-align: center;
      color: white;
      font-family: "Montserrat", sans-serif;
    }
    
    #bgVideo {
      position: absolute;
      top: 0px; 
      left: 0px; 
      min-width: 100%; 
      min-height: 100%;
      z-index: -1;
    }

最佳答案

你可以添加 overflow-x: hiddenbody

关于html - 隐藏视频背景溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52425967/

相关文章:

javascript - Jquery Scroller 需要在到达结束后停止滚动

html - 当我使用 jquery 计算 body 的高度时,绝对位置元素的高度不会被包括在内吗?

jquery - 使用 onClick 启用 css 样式

html - 输入文本框和按钮里面没有响应

javascript - 将 img 标签添加到文本区域以输入到文本文件中

javascript - 如何在没有按钮的情况下使用 jQuery UI 图标?

javascript - 添加类时停止 CSS 动画

javascript - 如何在没有 DIV 的情况下隐藏 <body>?

html - 将下拉菜单与容器的 100% 宽度居中对齐

css - "+"(加号)CSS 选择器是什么意思?