最近看b站广告,额,
然后好奇心打开官网,背景图怎么好像视频呢?
检查一下,还真是,
最后自己做了一个,没什么逻辑,点击查看最终效果(也就是我的demo)
于是好奇,看了一下好像蛮简单的,于是乎
,在失败了几次,反复看b站的代码,得到了经验
(其实就是在css上加点东西,把视频放在底层)
video{
height: 100%;
width: 100%;
position: absolute;
right: 0px;
bottom: 0px;
z-index:-99;
}
还有这个
<video autoplay loop muted src="kv.webm"></video>
就是这个,经过多次试验,发现muted是关键,(因为我一把他删了视频就没了,)
什么,你不认识video的属性?好吧我开始也忘了,百度了一下,hh
我把我的demo源码发一下吧
(其实就是布局,没什么参考价值,理论都在上面)
学习使我快乐,
加油各位萌新们。
(还有就是其实视频的大小,有需求的时候,会多加点东西
object-fit 这个东西建议了解一下哈,我也是看b站上加了,就看了一下
要看b站的代码,点进我的demo有梯子去那里。)
<!DOCTYPE html>
<html>
<style>
*{
margin: 0px;
padding: 0px;
}
html,body{
height: 100%;
width: 100%;
}
video{
height: 100%;
width: 100%;
position: absolute;
right: 0px;
bottom: 0px;
z-index:-99;
}
source{
width: 100%;
height: 100%;
}
p{
width: 100%;
font-size: 50px;
color: black;
text-align: center;
}
a{
position: absolute;
width: 150px;
height: 100px;
left: 43.5%;
top: 25%;
border-radius: 20%;
border:solid 3px ;
text-align: center;
padding: 20px;
background-color: rgba(1,1,1,0.3);
}
a:hover{
border-radius: 25%;
width: 160px;
left: 43.3%;
height: 110px;
}
h3{
position: absolute;
left: 41%;
top: 50%;
}
</style>
<body>
<p>仰望空调的兔子</p>
<a href="https://game.bilibili.com/sssj/">click</a>
<h3>跳转到正版的(o( ̄ヘ ̄o#))</h3>
<ul>
<li>仰望</li>
<li>天空</li>
<li>就是仰望幸福</li>
</ul>
<video autoplay loop muted src="kv.webm"></video><!-- 视频背景图就这一行 -->
</body>
</html>
最后有错误的地方,欢迎指出