html - 向下滚动时,如何使其与我的视频重叠?

标签 html css bootstrap-4

image[1]

所以我想这样做,当我从下面向下滚动 div 时,它会在我向下滚动时慢慢地与视频重叠。有点像 Minecraft 主页

最佳答案

将混合使用 z-indexposition:fixed 来获得您的目标...

#myVideo {
  position: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  z-index: -1
}

h1 {
  color: #fff;
  text-align: center;
}
<video autoplay muted loop id="myVideo">
  <source src="https://www.w3schools.com/howto/rain.mp4" type="video/mp4">
  Your browser does not support HTML5 video.
</video>

<h1>Some Heading</h1>

<div style="position:relative;height:auto;background-color:lightblue;font-size:20px; margin:50% 5%">
  Scroll Up and Down this page to see the parallax scrolling effect. This div is just here to enable scrolling. Tip: Try to remove the background-attachment property to remove the scrolling effect.
</div>

<div style="position:relative;height:auto;background-color:lightpink;font-size:16px; margin:40% 5%;">
  Scroll Up and Down this page to see the parallax scrolling effect. This div is just here to enable scrolling. Tip: Try to remove the background-attachment property to remove the scrolling effect.
</div>

关于html - 向下滚动时,如何使其与我的视频重叠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57949691/

相关文章:

javascript - 如何使用脚本和 HTML 从富文本编辑器获取包括 HTML 在内的数据

javascript - Html/JavaScript 预加载图像

html - 仅在所有 Bootstrap 元素上使用方边

html - Font Awesome 在浏览器中不起作用,但在 codepen 中有效

html - 如何在表格中固定标题?

css - 为什么我的 CSS 不适用于我所有的 EJS 循环?

html - 添加 Bootstrap 切换时,链接内的复选框行为错误

html - 如何更改所选文本的颜色?

javascript - 是否可以在 Tempus Dominus bootstrap 4 datetimepicker 中将 minDate 和 maxDate 设置为同一天?

css - Bootstrap 4 Sass - 动态改变主题