禁止html video 全屏时出现控制按钮

如何禁止html video 全屏时出现控制按钮

引用:https://www.cnblogs.com/codeskilla/p/4986630.html

禁止html video 全屏时出现控制按钮

 video::-webkit-media-controls {
            display:none !important;
        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在视频全屏显示添加自定义按钮,您可以使用HTML5的全屏API和JavaScript来实现。下面是一个简单的示例代码: ```html <!DOCTYPE html> <html> <head> <style> #video-container { position: relative; width: 100%; height: 0; padding-bottom: 56.25%; } #video { position: absolute; width: 100%; height: 100%; } #custom-button { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 999; display: none; } #video:-webkit-full-screen #custom-button, #video:-moz-full-screen #custom-button, #video:-ms-fullscreen #custom-button, #video:fullscreen #custom-button { display: block; } </style> </head> <body> <div id="video-container"> <video id="video" controls> <source src="your_video.mp4" type="video/mp4"> </video> <button id="custom-button">Custom Button</button> </div> <script> var video = document.getElementById('video'); var customButton = document.getElementById('custom-button'); customButton.addEventListener('click', function() { if (video.requestFullscreen) { video.requestFullscreen(); } else if (video.mozRequestFullScreen) { video.mozRequestFullScreen(); } else if (video.webkitRequestFullscreen) { video.webkitRequestFullscreen(); } else if (video.msRequestFullscreen) { video.msRequestFullscreen(); } }); </script> </body> </html> ``` 在上面的示例代码中,我们将视频包装在一个 `video-container` 容器中,并在其中添加了一个自定义按钮 `custom-button`。使用CSS的绝对定位和`display: none;`属性,我们将按钮放置在视频的中心,并将其初始显示设置为隐藏。 然后,通过JavaScript,我们为自定义按钮添加了一个点击事件监听器。当按钮被点击,我们使用各个浏览器提供的全屏API,例如 `requestFullscreen()`、`mozRequestFullScreen()`、`webkitRequestFullscreen()` 和 `msRequestFullscreen()` 来请求视频元素进入全屏模式。 请注意,全屏API在不同浏览器中的支持程度可能会有所不同,因此您可能需要根据需要进行适当的兼容性处理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值