智能客服
你问我答,随时在线为你解决问题

























加载视频完成前下半部分会被遮挡,加载完成再展示全部。
在使用iframe加载video时,iframe没有设置宽高,video加载完成后超过iframe的宽高就会撑开,导致页面异常。
视频在加载完成后改变了自身尺寸,而iframe未对其内容的大小变化进行有效限制。因此,iframe自动扩展以适应内容,导致外部页面布局异常。
- import { webview } from '@kit.ArkWeb';
-
- @Entry
- @Component
- struct WebComponent {
- controller: webview.WebviewController = new webview.WebviewController();
-
- build() {
- Column() {
- Web({ src: $rawfile('iframe.html'), controller: this.controller })
- .geolocationAccess(false)
- .fileAccess(true)
- }
- }
- }
- <!doctype html>
- <html lang="zh">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Video</title>
- </head>
- <style>
- <!-- CSS样式设置 -->
- video {
- width: 100%;
- height: 300px;
- object-fit: contain;
- }
- </style>
- <body>
- <div>
- <!-- 内联样式设置 -->
- <video width="100%" height="300px" controls>
- <source src="根据实际需要添加mp4格式的视频地址" type="video/mp4">
- </video>
- </div>
- </body>
- </html>
- <!doctype html>
- <html lang="zh">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Iframe</title>
- </head>
- <style>
- <!-- CSS样式设置 -->
- iframe {
- width: 100%;
- height: 300px;
- max-width: 100%;
- max-height: 300px;
- overflow: hidden;
- }
- </style>
- <body>
- <!-- 内联样式设置 -->
- <iframe src="./iframeVideo.html"
- frameborder="0"
- width="100%"
- height="300px"
- style="max-width: 100%; max-height: 300px; overflow: hidden;"
- allowfullscreen="allowfullscreen">
- </iframe>
- </body>
- </html>
智能客服
你问我答,随时在线为你解决问题
合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
解决方案
精准高效的一站式服务支持,助力开发者商业成功