在播放视频时使标题消失,可以通过以下几种方式实现:
<!DOCTYPE html>
<html>
<head>
<style>
#video-container {
position: relative;
width: 640px;
height: 360px;
}
#video-title {
position: absolute;
top: -30px;
left: 0;
width: 100%;
height: 30px;
background-color: rgba(0, 0, 0, 0.5);
color: #fff;
font-size: 16px;
line-height: 30px;
text-align: center;
transition: top 0.5s;
}
</style>
</head>
<body>
<div id="video-container">
<video id="video" src="video.mp4" controls></video>
<div id="video-title">Video Title</div>
</div>
<script>
var video = document.getElementById('video');
var title = document.getElementById('video-title');
video.addEventListener('play', function() {
title.style.top = '0';
});
video.addEventListener('pause', function() {
title.style.top = '-30px';
});
</script>
</body>
</html>
腾讯云相关产品推荐:
请注意,以上推荐的腾讯云产品仅供参考,具体选择还需根据实际需求进行评估和决策。
没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云