HTML+CSS实现视频背景页面

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/ 

参考自B站教程:12-视频背景页面_哔哩哔哩_bilibili

  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值