先看效果图
主要代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
*{
padding: 0;
margin: 0;
}
.banner{
width: 100%;
min-width: 1200px;
height: 500px;
overflow: hidden; /***溢出时隐藏*/
position: relative;
background: #000;
}
.banner video{
width: 100%;
position: relative;
top: -100px;
opacity: 0.4; /***改变透明度,可以让视频模糊些**/
}
.banner h2{
position: absolute;
left: 0;
top: 0;
color: #fff;
width:100%;
text-align: center;
font-size: 50px;
font-family: "微软雅黑";
padding: 80px 0;
}
</style>
</head>
<body>
<section class="banner">
<video loop autoplay muted="muted">
<source src="video/city.mp4"></source>
</video>
<!--要让字压住视频, 需要用定位-->
<h2>具有大众消费开胃特色 <br />中国传统手工泡菜第一品牌</h2>
</section>
</body>
</html>
完整实现 请参考 Webfront 工程