因此我在后台有一个视频,我试图在该视频上放置一个导航栏。因此,我使它们都可以单独工作,但是当我将它们放在一起时,视频将覆盖导航栏。现在我不知道这是怎么回事。我已经添加了尝试重新排列代码的尝试,以及在网上寻找指南的过程,但仍未找到任何细节。
这是我的html代码:
*{
margin: 0;
padding: 0;
}
.container{
width: 90%;
margin: 0 auto
}
.navbar {
width:100%;
overflow: hidden;
height: 40px;
line-height: 40px;
background: #fff;
border-bottom: 2px solid black;
}
.logo{
width: 80px;
float:left;
}
/* this is for ul tag */
.menu{
float:right;
}
.menu li{
float:left;
width:120px;
height: 40px;
line-height: 40px;
text-align: center;
list-style: none;
}
.menu li a{
color: #000;
text-decoration: none;
font-family: calibri;
text-transform: uppercase;
display:block;
}
.menu li:hover{
background: #dc3545
}
.menu li a:hover{
color: #fff
}
#myVideo {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
filter: brightness(25%);
}
<head>
<title>Guide to Sheffield Student Nightlife - Home Page</title>
<link rel="stylesheet" href="C:\Users\paulk\Desktop\Web Dev\style.css">
</head>
<body>
<div class="navbar">
<div class="container">
<div class="logo_div">
<a href="https://www.google.com/"><img src="C:\Users\paulk\Desktop\Web Dev\TheGuide.png" alt="" class="logo"></a>
</div>
<div class="navbar_links">
<ul class="menu">
<li><a href="#">Home</a></li>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page 2</a></li>
<li><a href="#">About us</a></li>
</ul>
</div>
</div>
</div>
<video playsinline autoplay muted loop poster="TheGuide.jpg" id="myVideo">
<source src="C:\Users\paulk\Desktop\Web Dev\Fire.mp4" type="video/mp4">
</video>
</body>
答案 0 :(得分:0)
由于您的视频处于定位状态:已修复,因此您可以使用负Z索引
#myVideo {z-index: -1;}
完整示例:
*{
margin: 0;
padding: 0;
}
.container{
width: 90%;
margin: 0 auto
}
.navbar {
width:100%;
overflow: hidden;
height: 40px;
line-height: 40px;
background: #fff;
border-bottom: 2px solid black;
}
.logo{
width: 80px;
float:left;
}
/* this is for ul tag */
.menu{
float:right;
}
.menu li{
float:left;
width:120px;
height: 40px;
line-height: 40px;
text-align: center;
list-style: none;
}
.menu li a{
color: #000;
text-decoration: none;
font-family: calibri;
text-transform: uppercase;
display:block;
}
.menu li:hover{
background: #dc3545
}
.menu li a:hover{
color: #fff
}
#myVideo {
position: fixed;
z-index: -1;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
filter: brightness(25%);
}
<div class="navbar">
<div class="container">
<div class="logo_div">
<a href="https://www.google.com/"><img src="C:\Users\paulk\Desktop\Web Dev\TheGuide.png" alt="" class="logo"></a>
</div>
<div class="navbar_links">
<ul class="menu">
<li><a href="#">Home</a></li>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page 2</a></li>
<li><a href="#">About us</a></li>
</ul>
</div>
</div>
</div>
<video playsinline autoplay muted loop poster="TheGuide.jpg" id="myVideo">
<source src="https://ak8.picdn.net/shutterstock/videos/8733538/preview/stock-footage-sydney-australia-january-social-media-internet-platform-networks-social-media-allows.webm" type="video/mp4">
</video>