【发布时间】:2021-08-17 15:45:49
【问题描述】:
我是 Bootstrap 的新手,我尝试使用视频背景实现代码为 navbar。
我尝试过的:
HTML 代码:
<html>
<head>
<title>Medical</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="CSS/wstyle.css">
</head>
<body>
<section class="section-header">
<div class="container">
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">
<img src="images/LOGO.png" style="width:60%" ;>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo02">
<ul class="navbar-nav ml-auto mt-2 mt-lg-0">
<li class="nav-item pl-4 pl-2 active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item pl-4 pl-2">
<a class="nav-link" href="#">About</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
</div>
</section>
<section class="video-bg">
<div class="container">
<video id="video" autoplay loop>
<source src="video/video.mp4" type="video/mp4">
</video>
</div>
</section>
<div id="location" class="container">
<img src="images/image1.PNG" alt="IMAGE" width="100%" height="600px">
</div>
</body>
</html>
我已将 CSS 文件 (wstyle.css) 包含在 CSS 文件夹中,并将视频 (video.mp4) 包含在视频文件夹中。
CSS 代码为:
CSS (wstyle.css)
.video-bg{
position:fixed;
z-index: -1;
}
现在,视频在 Internet Explorer 和 Google Chrome 中的播放方式不同,视频也不会作为导航栏的背景播放。如何让视频播放作为导航栏的背景?
【问题讨论】:
标签: html css bootstrap-4 background nav