【问题标题】:prevent background window scroll up to the top when other window popup in angular 7/8当其他窗口以 7/8 角度弹出时,防止背景窗口向上滚动到顶部
【发布时间】:2021-01-01 19:02:35
【问题描述】:

所以当我单击标签时,我会在页面中间打开一个弹出窗口,但是,当弹出窗口显示时,背景窗口总是一直滚动到顶部。我希望背景页面不要一直向上滚动,而是留在原处。以下是代码

HTML

<div class="notSU">
  <a (click)="open()">open popup window</a>
</div>

javascript(ts 文件)

open(){
 const window: WindowRef = this.windowService.open({
          title: 'My Window',
          content: 'My Content!',
          width: 450,
          height: 200
      });

      window.result.subscribe((result) => {
          if (result instanceof WindowCloseResult) {
              console.log('Window was closed!');
          }
      });
}

CSS

.notSU{
   overflow:hidden !important;
}

【问题讨论】:

    标签: javascript css angular angular7 angular8


    【解决方案1】:

    如果您的模态窗口代码位于页面顶部,并且位置设置为相对或绝对,这可能是它滚动到顶部的原因。尝试在下面提供 .notSU 这些 CSS 设置。 position: fixed; 相对于浏览器窗口定位元素,而不是它可能嵌套的父元素。

    .notSU {
      position: fixed;
      z-index: 400;
      left: 50%;
      top: 50%;
      transform: translate(-50% -50%);
      max-width: 450px;
      max-height: 200px;
      width: 100%;
      height: 100%;
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多