前端入坑纪 43
继续更,其实很早就想写这么个东西了。今天无意中在油管上看到,那就发一个吧!
好,入正题!
OK,first things first! github项目地址

HTML 结构
<div class="mainWrp">
<div class="vdoWrp">
<video src="http://www.runoob.com/try/demo_source/mov_bbb.mp4" autoplay muted loop></video>
</div>
<div class="txtCont">
<div class="contWrp">
<h1>一如你所见</h1>
<h5>动画浮之于下</h5>
</div>
</div>
</div>
div.vdoWrp 就是包裹视频video。div.txtCont 包裹文字内容,并且是绝对定位的。
CSS 结构
body {
margin: 0;
padding: 0;
}
.vdoWrp {
width: 100%;
height: 100vh;
overflow: hidden;
}
// 加min- 是为了让视频比例不失,而高度宽度谁大听谁的
.vdoWrp video {
min-width: 100%;
min-height: 100vh;
}
// 绝对定位盖在视频动画上
.txtCont {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
top: 0;
left: 0;
width: 100%;
height: 100vh;
z-index: 1;
background-color: rgba(159, 190, 255, 0.6);
color: #fff;
line-height: 1.6;
text-align: center;
}
div.txtCont用了flex布局(不晓得的小伙伴,赶紧百度吧!),其实现在很多效果比以前好做多了,因为HTML5新的东西越来越多,也越来越方便!
好了,到此,本文告一段落!感谢您的阅读!祝您和您的家人身体健康,阖家幸福!
网友评论