HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>视频背景页面</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header class="v-header container">
<div class="full-screen-video-wrapper">
<video src="video/190828_27_SuperTrees_HD_17.mp4" autoplay loop muted></video>
</div>
<div class="header-overlay"></div>
<div class="header-content">
<h1>绿色家园</h1>
<p>内容.........................
..............................</p>
<a href="#" class="btn">阅读更多</a>
</div>
</header>
<section class="section section-a">
<div class="container">
<h1>关于我们</h1>
<p>介绍....</p>
</div>
</section>
<section class="section section-b">
<div class="container">
<h1>联系我们</h1>
<p>介绍....</p>
</div>
</section>
</body>
</html>
CSS:
*{
box-sizing: border-box;
}
body{
margin: 0;
line-height: 1.5;
overflow-x: hidden;
color: #333;
}
/* */
.v-header{
display: flex;
height: 100vh;
align-items: center;
justify-content: center;
color: #fff;
}
.container{
max-width: 960px;
padding-left: 1rem;
padding-right: 1rem;
margin: auto;
text-align: center;
}
.full-screen-video-wrapper{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100vh;
overflow: hidden;
}
.full-screen-video-wrapper video{
min-width: 100vw;
min-height: 100vh;
}
.header-overlay{
position: absolute;
height: 100vh;
width: 100vw;
top: 0;
left: 0;
background-color: rgb(179, 252, 130);
opacity: 0.2;
z-index: 1;
}
.header-content{
z-index: 2;
}
.header-content h1{
font-size: 4rem;
padding-bottom: 0;
}
.header-content p{
font-size: 1.5rem;
padding-bottom: 2rem;
}
.btn{
font-size: 1.2rem;
color: #fff;
background-color: #79dbbc;
padding: 1rem 1.8rem;
text-decoration: none;
letter-spacing: 1px;
}
.section{
padding: 1rem 0;
}
.section-b{
color: white;
background-color: black;
}
/* */
@media(max-width:960px){
.container{
padding-left: 3rem;
padding-right: 3rem;
}
}
效果图:
video资源网站:https://mazwai.com/ 文章来源:https://www.toymoban.com/news/detail-763826.html
参考自B站教程:12-视频背景页面_哔哩哔哩_bilibili文章来源地址https://www.toymoban.com/news/detail-763826.html
到了这里,关于HTML+CSS实现视频背景页面的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!