Vue+js realizes the fade in and fade out of the video, for your reference, the specific content is as follows A simple video fade-in and fade-out effect is shown in the figure The editor directly posted the code. If you are interested, you can copy and run it. Thank you <template> <div class="video-css"> <div class="videocss" ref="videodom" style="background-color:black;"> <video width="100%" ref="play" style="opacity: 1" :src="videoSrc2"></video> </div> <div class="video-but"> <el-button type="primary" @click="play()">Play</el-button> <el-button type="primary" @click="pause()">Pause</el-button> <el-button type="primary" @click="fadeIn(100)">Fade in</el-button> <el-button type="primary" @click="fadeOut(100)">Fade out</el-button> </div> </div> </template> <script> export default { data() { return { videoSrc: require('../../assets/web_1496003377.mp4'), videoSrc2: require('../../assets/video.mp4') } }, methods: { play() { this.$refs.play.play() }, pause() { this.$refs.play.pause() }, fadeIn(speed) { let that = this var speed = speed || 30 ; var num = 0; var st = setInterval(function(){ num++; that.$refs.play.style.opacity = num/10; if (num>=10) { clearInterval(st); } }, speed); }, fadeOut(speed) { let that = this var speed = speed || 30 ; var num = 10; var st = setInterval(function(){ num--; that.$refs.play.style.opacity = num / 10; if (num<=0){ clearInterval(st); } }, speed); } } } </script> <style lang="less" scoped> .video-css { .videocss { width: 800px; height: 450px; display: flex; justify-content: center; } .video-but { display: flex; margin-top: 20px; justify-content: flex-start; align-content: flex-start; } } </style> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: A brief analysis of the tutorial on installing MySQL 8.0.18 on CentOS 6.8 (RPM method)
>>: How to shut down/restart/start nginx
This article shares the specific code of JavaScri...
Learn about similar methods for getting character...
Table of contents ESLint plugin installation in H...
Table of contents Preface Introduction ngram full...
Open the centos yum folder Enter the command cd /...
Tetris is a very classic little game, and I also ...
The form code is as shown in the figure. The styl...
Table of contents 1. How to view the binary data ...
Use the browser (webdriver)-based selenium techno...
Why use prettier? In large companies, front-end d...
This article example shares the specific code of ...
Download source code git clone https://github.com...
Pull the image # docker pull codercom/code-server...
Simple XHTML web form in web design 5. Technique ...
This article shares the installation and configur...