html5 video标签制作背景图

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ken_ding/article/details/84565928

代码:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    * {
        margin: 0px;
        padding: 0px;
    }

    video {
        position: fixed;
        right: 0px;
        bottom: 0px;
        max-width: 100%;
        min-height: 100%;
        height: auto;
        width: auto;
    }
</style>

<body>
    <video muted autoplay="autoplay" loop="loop">
        <source src="../1.mov">
    </video>
</body>

</html>

效果:
在这里插入图片描述
浏览器兼容性:
适用所有主流浏览器
ps:
muted 属性为了在chorme可以自动播放视频
autoplay 视屏自动播放
loop 视频循环播放

猜你喜欢

转载自blog.csdn.net/ken_ding/article/details/84565928
今日推荐