代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<style>
* {
margin: 0px;
padding: 0px;
}
video {
position: fixed;
right: 0px;
bottom: 0px;
max-width: 100%;
min-height: 100%;
height: auto;
width: auto;
}
</style>
<body>
<video muted autoplay="autoplay" loop="loop">
<source src="../1.mov">
</video>
</body>
</html>
效果:

浏览器兼容性:
适用所有主流浏览器
ps:
muted 属性为了在chorme可以自动播放视频
autoplay 视屏自动播放
loop 视频循环播放
本文介绍如何使用HTML和CSS创建全屏背景视频效果,包括代码示例和浏览器兼容性说明。通过设置video标签的属性,如muted、autoplay和loop,实现视频静音、自动播放和循环播放。
1万+

被折叠的 条评论
为什么被折叠?



