css - 视频无法播放且太大
问题描述
我正在创建一个基于视频作为主页背景的网站我遇到了一个问题,我不知道问题是什么,但我遵循了一个在线教程,似乎我愿意放入我的视频网站已显示但无法播放,即使全屏查看也太大。
这是代码:
<html>
<head>
<!-- settings -->
<title> Prestige</title>
<link rel="shortcut icon" type="image/png" href="images/favicon.png"
<link rel="stylesheet" type="text/css" href="css/style.css">
<meta charset="UTF-8">
<meta name="viewport" conetent="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
</head>
<body>
<header class="v-header container">
<div class="fullscreen-video-wrap">
<video src="Intro.mp4" autoplay="true" loop="true"></video>
</div>
</header>
</body>
解决方案
您可以尝试在代码片段中上传您的代码以复制它,看看您的代码是否存在问题。你可以试试这段代码:
HTML
<video autoplay muted loop id="myVideo">
<source src="rain.mp4" type="video/mp4">
</video>
<div class="content">
<h1>Heading</h1>
<p>Lorem ipsum...</p>
<!-- Use a button to pause/play the video with JavaScript -->
<button id="myBtn" onclick="myFunction()">Pause</button>
</div>
CSS:
#myVideo {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
}
/* Add some content at the bottom of the video/page */
.content {
position: fixed;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
color: #f1f1f1;
width: 100%;
padding: 20px;
}
/* Style the button used to pause/play the video */
#myBtn {
width: 200px;
font-size: 18px;
padding: 10px;
border: none;
background: #000;
color: #fff;
cursor: pointer;
}
#myBtn:hover {
background: #ddd;
color: black;
}
JS
<script>
// Get the video
var video = document.getElementById("myVideo");
// Get the button
var btn = document.getElementById("myBtn");
// Pause and play the video, and change the button text
function myFunction() {
if (video.paused) {
video.play();
btn.innerHTML = "Pause";
} else {
video.pause();
btn.innerHTML = "Play";
}
}
</script>
你也可以在这里查看。
推荐阅读
- python - Python请求未返回整页内容
- java - 如何在 Apache Tomcat 8/9 中设置 HTTP Expect-CT 标头?
- sql - SQL 窗口函数以每日级别计算不同的月份日期
- reactjs - 我正在尝试将函数从 app.js 传递到详细信息屏幕。但我不断收到此错误(在导航中发现了不可序列化的值)
- java - 如何使用我的密钥使用 javax.crypto.Cipher 进行加密?
- background - 渐变透明PNG
- kubernetes - minikube apiserver.service-node-port-range 不喜欢逗号分隔的端口列表
- makefile - GN Build 添加具有 makefile 的子目录
- swift - 无法在 Apple Silicon (M1) 上的 SceneKit 中将 AVCaptureVideoPreviewLayer 设置为漫反射内容
- javascript - 带有斜杠的 JsFiddle URL 被评估为正确的链接