首页 > 解决方案 > 有没有办法在 YouTube iframe 上放置一个 div 标签以实现全屏显示?

问题描述

有没有办法在 YouTube 上放置一个 div 标签以iframe实现全屏显示?

iframe我可以使用以下代码在 YouTube 上放置一个 div 标签:

<html>
    <head></head>
    <body>
        <div style="position:relative">
            <iframe width="560" height="315" src="https://www.youtube.com/watch?v=tQ0yjYUFKAE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
            <div style="position:absolute;top:0px;left:0px;background:#000;width:500px;height:500px;"></div>
        </div> 
    </body>
</html>

但是当iframe上面的 YouTube 全屏时,添加的 div 标签会消失。

请让我知道是否有解决此问题的方法。

标签: htmlcssyoutube-iframe-api

解决方案


推荐阅读