时间:2021-05-26
本文实例为大家分享了Vue制作登录主页动态背景短视频的具体代码,供大家参考,具体内容如下
一、HTML代码
<source src="../assets/video/G1s.mp4" type="video/mp4"/>注:src的路径根据自己的需要改变;
video标签无法自动播放 刷新后无法自动播放;
解决方法:给video标签添加muted属性,可写为muted或完整写法:muted=“muted”
<template> <div class="homepage-hero-module"> <div class="video-container"> <div :style="fixStyle" class="filter"> <!--内容--> </div> <video :style="fixStyle" autoplay loop muted class="fillWidth" v-on:canplay="canplay"> <source src="../assets/video/G1s.mp4" type="video/mp4"/> 浏览器不支持 video 标签,建议升级浏览器。 <source src="../assets/video/G1w.webm" type="video/webm"/> 浏览器不支持 video 标签,建议升级浏览器。 </video> <div class="poster hidden" v-if="!vedioCanPlay"> <img :style="fixStyle" src="../assets/video/G1.jpg" alt=""> </div> </div> </div></template>二、css代码
<style scoped> .homepage-hero-module, .video-container { position: relative; height: 100vh; overflow: hidden; } .video-container .poster img{ z-index: 0; position: absolute; } .video-container .filter { z-index: 1; position: absolute; background: rgba(0, 0, 0, 0.4); width: 100%; } .fillWidth { width: 100%; }</style>三、JavaScript----代码
name: ' *** ' 自定义
export default { name: 'Video', data() { return { vedioCanPlay: false, fixStyle: '' } }, methods: { canplay() { this.vedioCanPlay = true } }, mounted: function() { //屏幕自适应 window.onresize = () => { const windowWidth = document.body.clientWidth const windowHeight = document.body.clientHeight const windowAspectRatio = windowHeight / windowWidth let videoWidth let videoHeight if (windowAspectRatio < 0.5625) { videoWidth = windowWidth videoHeight = videoWidth * 0.5625 this.fixStyle = { height: windowWidth * 0.5625 + 'px', width: windowWidth + 'px', 'margin-bottom': (windowHeight - videoHeight) / 2 + 'px', 'margin-left': 'initial' } } else { videoHeight = windowHeight videoWidth = videoHeight / 0.5625 this.fixStyle = { height: windowHeight + 'px', width: windowHeight / 0.5625 + 'px', 'margin-left': (windowWidth - videoWidth) / 2 + 'px', 'margin-bottom': 'initial' } } } window.onresize() } }四、效果演示
由于上传大小限制,只能剪短的gif动画了。
五、HTML版
视频呢下载和html版代码在官网最下方:https://coverr.co
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
现在的短视频推广是非常火的,因此淘宝的很多板块也都融入了短视频的元素,像主页大家都可以给商品制作短视频发布上去,那么淘宝逛逛也是可以发布短视频的,怎么发布呢?一
vue不可以拍照片,vue只可以拍摄3秒的短视频,即可以拼接在一起的短视频。 Vue系列产品为3D自然环境的动画制作和渲染提供了一系列的解决方案。Vue系列有
vue是一款专为用户打造的短视频制作神器,vue不能改字体大小,只能使用系统默认的字体大小。 VUE是iOS和Android平台上的一款手机视频拍摄与美化工具
抖音APP版本为12.4.0,其抖音视频背景是无法修改的,只能对其个人主页的背景图片进行修改。其修改方法如下: 1、首先打开抖音短视频APP图标; 2、接着
把抖音视频设置成锁屏的方法: 1、在抖音短视频APP中,下载想要设置成动态锁屏的视频。 2、然后下载火萤视频APP,点击我的制作livephoto,制作刚刚