如何在视频停止播放后隐藏或淡出HTML视频,然后显示下面的h1标题



我想在视频结束后隐藏/淡出视频。我希望h1标题在视频结束时出现在相同的位置(隐藏/淡出)。

如何在JavaScript或CSS中实现这一点?

HTML代码:

<div class="header__title">
<h1>
When
<!-- Green highlight effect -->
<span class="highlight">banking</span>
meets<br />
<span class="highlight">the future</span>
</h1>
<h4>The future of money is here.</h4>
<img
src="img/Javacoin homepage picture.png"
class="header__img"
alt="Minimalist bank items"
/>
</div>
<div class="background__video">
<video autoplay muted>
<source src="Javacoin Corporate Intro - Final.mp4" type="video/mp4">
</video>
</div>

const video = document.getElementById('vid');
video.onended = () => {
document.getElementsByClassName('background__video')[0].style.opacity = "0";
document.getElementsByClassName('header__title')[0].style.opacity = "100";
}
.header__title {
transition: 1s;
opacity: 0;
}
.background__video {
transform : translateY(-50%);
transition: 1s;
}
<div class="header__title">
<h1>
When
<!-- Green highlight effect -->
<span class="highlight">banking</span> meets
<br />
<span class="highlight">the future</span>
</h1>
<h4>The future of money is here.</h4>
<img src="img/Javacoin homepage picture.png" class="header__img" alt="Minimalist bank items" />
</div>
<div class="background__video">
<video autoplay muted id="vid">
<source src="https://www.radiantmediaplayer.com/media/big-buck-bunny-360p.mp4" type="video/mp4">
</video>
</div>

这个可以!

相关内容

  • 没有找到相关文章

最新更新