html - 如何在页面的视频背景下放置列表?

标签 html css

我使用固定位置的视频标签作为页面顶部的背景。现在我想在它下面放置一个列表,但我的列表没有很好的定位,而是一个绝对位置。我不知道我的代码哪里错了。

我该怎么做才能解决这个问题?

* {
  border: 0;
  margin: 0;
  padding: 0;
}
a {
  text-decoration: none;
  color: white;
}
ul {
  list-style-type: none;
}
.mymenu {
  float: left
}
.mymenu > li {
  background-color: #ff9933;
  float: left;
  height: 60px;
  line-height: 60px;
  text-align: center;
  padding: 0 80px;
}
.mymenu li:hover {
  background: #e62e00;
  cursor: pointer;
}
.mymenu li ul {
  position: absolute;
  left: 415px;
  display: none
}
.mymenu li ul li {
  background-color: #ff6600;
  float: left;
  padding: 0 42px;
  left: 0;
}
.mymenu li:hover ul {
  display: block;
}
/*==================================*/

.myvideo {
  position: fixed;
  height: 100%;
  width: 100%;
  z-index: -10;
  overflow: hidden;
  top: 0;
  left: 0;
}
.myvideo video {
  position: absolute;
  top: 0;
  left: 0;
  min-height: 100%;
  min-width: 100%;
}
.myvideo .mycontent {
  position: absolute;
  height: 100%;
  width: 100%;
  color: #fff;
  background: rgba(0, 0, 0, .2)
}
.clear {
  clear: both;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="css/style.css">
  <title>Document</title>
</head>

<body>
  <div class="myvideo">
    <video autoplay loop muted>
      <source src="video/Vue%20Js%20Tutorial%20Intro%20with%20TodoList%20-%203%20For%20loops%20and%20if.mp4">
    </video>
    <div class="mycontent">
      <h1>welcome</h1>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore, obcaecati.</p>
    </div>
  </div>
  <div class="clear"></div>
  <ul class="menu2">
    <li><a href="#">section 1</a>
    </li>
    <li><a href="#">section 2</a>
    </li>
    <li><a href="#">section 3</a>
    </li>
    <li><a href="#">section 4</a>
    </li>
    <li><a href="#">section 5</a>
    </li>
  </ul>
</body>

</html>

最佳答案

这是因为 .mycontent 位于绝对定位的 .myvideo div 中。尝试像这样重构 HTML:

<body>
  <div class="myvideo">
    <video autoplay loop muted>
      <source src="video/Vue%20Js%20Tutorial%20Intro%20with%20TodoList%20-%203%20For%20loops%20and%20if.mp4">
    </video>
  </div>
  <div class="mycontent">
    <h1>welcome</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore, obcaecati.</p>
    <div class="clear"></div>
    <ul class="menu2">
      <li><a href="#">section 1</a>
      </li>
      <li><a href="#">section 2</a>
      </li>
      <li><a href="#">section 3</a>
      </li>
      <li><a href="#">section 4</a>
      </li>
      <li><a href="#">section 5</a>
      </li>
    </ul>
  </div>
</body>

在您的原始 HTML 中,实际上是 .mycontent 具有绝对定位,而不是列表。

关于html - 如何在页面的视频背景下放置列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38794451/

相关文章:

jquery - 输入类型文本的任何监听器

html - 在 Watir Ruby 中访问顺序相同的元素

javascript - 即使单击后也更改按钮颜色

javascript - 在 Canvas 上在线绘制另一个边框

php - 更改 Wordpress 主题中的 "Load More"按钮的最佳方法是什么?

使用类选择器时,jquery click 事件被触发多次

html - 使用 css 和 HTML 排列 div

css - 如何向 Rails 应用程序添加自定义字体?

javascript - 通过HTML5流式传输本地文件

iOS HTML5 日期选择器不接受宽度 : 100%;