ios - 位置 : fixed is not working in iOS when loading Angular site inside iframe in Ionic 3

标签 ios css angular ionic-framework iframe

简要说明我们正在努力实现的目标

我们正在开发一个Angular 应用程序。我们使用相同的代码库为 Web 和移动开发它。手机版包含很多功能,例如推送通知短信订阅等。我们希望将手机版发布到App store和Play store。我们使用简单的 Ionic 3 应用程序将其构建到 Android 和 iOS。

Ionic 3 应用程序仅包含一个页面,我们在其中加载 iframe 中的 Angular 网站

Ionic 页面的 HTML

<ion-content>
  <iframe class= 'webPage' [src]="iframeSrc" webkitAllowFullScreen mozallowfullscreen allowFullScreen>
  </iframe>
</ion-content>

Ionic页面的TS

export class HomePage {
  iframeSrc: any;

  sanitizer: DomSanitizer;
  url: string = 'https://angular-load-ionic-iframe.stackblitz.io';

  constructor( sanitizer: DomSanitizer ) {
    this.sanitizer = sanitizer;
    this.iframeSrc = this.sanitizer.bypassSecurityTrustResourceUrl(this.url);

  }
}

查找The Github Repository Ionic 3 应用程序 Here .

我创建了 StackBlitz类似于 My Angular 应用程序的 Angular 元素。找到它Here .

My Issue

In my application, app-header and app-footer need to be fixed to ViewPort and other content should be able to scroll. I successfully achieved this for Android But in iOS, app-header and app-footer are not fixed to ViewPort and those are scrolling with other content when I load my Angular application inside an iframe in Ionic app.

header.component.html

<header>
  <div class="main">
        <h3>Countries</h3>
    </div>
</header>

header.component.css

.main {
    background-color: #46454A;
    color: rgba(255,255,255,.6);
    padding:5px 50px;
}

header{
  position: fixed;
  z-index: 10;
  top: 0;
  width: 100%;
}

footer.component.html

<footer class="footer">
    <h3>This is footer</h3>
</footer>

footer.component.css

.footer{
    position: fixed;
    bottom: 0;
    width: 100%;
  background-color:#47454b;
}
h3 {
  color: white;
  padding:0px 50px;
}

我无法弄清楚CSS iOS 问题还是它是在我在 iframe 中加载 Angular 网站时发生的>。挣扎了一天,还是没有成功。如果有人可以帮助我解决此问题,我将不胜感激,如果有人需要有关此问题的更多详细信息,请随时发表评论。

最佳答案

将此 css 放入您的 style.css

body {
    margin: 0px;
}
h3 {
  color: white;
  padding:0px 50px;
}
my-app{
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
}

app-header,app-home,app-footer{
  position: absolute;
  left: 0;
  width: 100%;
}
app-header,app-footer{
  text-align: center;
  color: white;
  height: 50px;
   background-color:#47454b;
}
app-header{
  top:0;
}
app-footer{
  bottom:0;
}
app-home {
  top: 50px;
  bottom: 50px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

删除所有 header.component.cssfooter.component.css

这是 stackblitz 链接 https://stackblitz.com/edit/angular-load-ionic-iframe-knkgq4?file=src%2Fstyles.css

关于ios - 位置 : fixed is not working in iOS when loading Angular site inside iframe in Ionic 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54846808/

相关文章:

javascript - 来自外部 API 的 Angular2 http.get

iOS - 编译依赖

ios - Swift 加速度计数据不更新 UILabel 阴影

iphone - 清除部分 UIImage

javascript - 如何更改 Facebook 登录按钮的样式?

javascript - jQuery timpicker 方法内的 Angular2 组件上下文

javascript - Angular Protractor 在它上面循环 ('some test' ) 测试

ios - 第三方SDK集成前需要考虑哪些安全参数

jquery - Fancybox 弹出 - 背景页面的下半部分消失

Javascript/Jquery 高效放大编码