html - iframe 不透明度会破坏视频元素全屏。变黑
问题描述
Page A
有一个加载Page B
包含视频的 iframe。
iframe 仅在元素悬停时可见。它使用不透明度隐藏。
我用户在视频上单击全屏,并且框架的不透明度在下面发生变化。这会导致视频变黑。
下面的代码将模拟这一点,只是在超时后设置不透明度而不是悬停进/出(悬停在我们测试过的各种设置中是喜怒无常的)。
我正在寻找这个问题的解决方案。
一种选择是从父页面发送消息以在 iframe 上设置一个类,例如is-fullscreen
然后将 css 添加到父页面以确保opacity: 1 !important
视频何时处于全屏模式。这看起来很麻烦而且不太理想,所以我想知道还有什么选择。
索引.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Video Test</title>
</head>
<body>
<iframe
id="container"
frameborder="0"
src="frame.html"
name="container"
width="600"
height="600"
></iframe>
<script>
setTimeout(function () {
document.getElementById('container').style.opacity = 0;
}, 3000);
</script>
</body>
</html>
框架.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title></title>
</head>
<body>
<video
id="video"
src="https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/1080/Big_Buck_Bunny_1080_10s_1MB.mp4"
width="400"
autoplay=""
loop=""
playsinline
controls=""
muted
></video>
</body>
</html>
解决方案
推荐阅读
- javascript - 如何防止两个 Node 进程同时运行时插入完全相同的数据库记录?
- html - 以前如何设置按钮的左右边框?
- php - 应用 ssl 后 Laravel 默认邮件不起作用
- c++ - 绘制数千个立方体时性能不佳
- keras - K.function的第三个参数,更新需要有新旧权重对以外的操作吗?
- android - 手机处于锁定模式时如何在特定推送通知上打开应用程序屏幕
- swift - 如何快速从sqlite中检索图像的ID(保存在BLOB中)
- python - 限制标记词的输出范围
- java - org.apache.axis2.AxisFault: HTTP (401) 未经授权的地址:
- java - java - 如何在java中使用三个嵌套的for循环来实现带有_的倒金字塔?