如何制作离子弹出式以显示扳机上方?

发布于 2025-02-07 06:32:46 字数 1894 浏览 1 评论 0原文

我有一个内联离子弹出物:

<!-- Show popover above trigger -->
<ion-button id="button">Demo</ion-button>
<ion-popover trigger="button" side="top">
  <ng-template>
    <ion-content>
      <ion-item>
        <ion-label>
          1. Test
        </ion-label>
      </ion-item>
      <ion-item>
        <ion-label>
          2. Test
        </ion-label>
      </ion-item>
      <ion-item>
        <ion-label>
          3. Test
        </ion-label>
      </ion-item>
      <ion-item>
        <ion-label>
          4. Test
        </ion-label>
      </ion-item>
    </ion-content>
  </ng-template>
</ion-popover>

这就是它的样子:

我什至没有看到其他项目在屏幕上。 因此,我想知道是否以及如何使触发器上方的弹出窗口显示。

我尝试了side =“ top”。它仅使弹出窗口从触发器的上角而不是在下角开始,它似乎不会使弹出模板出现在触发器上方(在这种情况下为简单的离子按钮)。


版本信息:

Ionic:

   Ionic CLI                     : 6.19.1 (/opt/homebrew/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 6.1.9
   @angular-devkit/build-angular : 14.0.0
   @angular-devkit/schematics    : 13.3.5
   @angular/cli                  : 14.0.0
   @ionic/angular-toolkit        : 6.1.0

Capacitor:

   Capacitor CLI      : 3.5.1
   @capacitor/android : not installed
   @capacitor/core    : 3.5.1
   @capacitor/ios     : not installed

Utility:

   cordova-res                          : not installed globally
   native-run (update available: 1.6.0) : 1.5.0

System:

   NodeJS : v16.15.0 (/opt/homebrew/Cellar/node@16/16.15.0/bin/node)
   npm    : 8.5.5
   OS     : macOS Monterey

I have an inline ionic popover:

<!-- Show popover above trigger -->
<ion-button id="button">Demo</ion-button>
<ion-popover trigger="button" side="top">
  <ng-template>
    <ion-content>
      <ion-item>
        <ion-label>
          1. Test
        </ion-label>
      </ion-item>
      <ion-item>
        <ion-label>
          2. Test
        </ion-label>
      </ion-item>
      <ion-item>
        <ion-label>
          3. Test
        </ion-label>
      </ion-item>
      <ion-item>
        <ion-label>
          4. Test
        </ion-label>
      </ion-item>
    </ion-content>
  </ng-template>
</ion-popover>

And this is what it looks like:
enter image description here

I don't even see the other items as they are off screen.
So I was wondering if and how I can make the popover show above the trigger.

I tried the side="top". It only makes the popover start at the upper corner of the trigger instead of at the lower corner, it does not seem to make the popover template appear above the trigger (in this case a simple ion-button).


Version info:

Ionic:

   Ionic CLI                     : 6.19.1 (/opt/homebrew/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 6.1.9
   @angular-devkit/build-angular : 14.0.0
   @angular-devkit/schematics    : 13.3.5
   @angular/cli                  : 14.0.0
   @ionic/angular-toolkit        : 6.1.0

Capacitor:

   Capacitor CLI      : 3.5.1
   @capacitor/android : not installed
   @capacitor/core    : 3.5.1
   @capacitor/ios     : not installed

Utility:

   cordova-res                          : not installed globally
   native-run (update available: 1.6.0) : 1.5.0

System:

   NodeJS : v16.15.0 (/opt/homebrew/Cellar/node@16/16.15.0/bin/node)
   npm    : 8.5.5
   OS     : macOS Monterey

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜声 2025-02-14 06:32:46

我相信您正在寻找这样的东西。
您可以在这里找到更多有关它的信息: https://ionicframework.com/docs/docs/docs/api/ popover#inline-popover

<!-- Show popover above trigger -->
<ion-button id="side-button">Click to open popover</ion-button>
<ion-popover trigger="side-button" side="top">
  <ng-template>
    <ion-content>Popover Content</ion-content>
  </ng-template>
</ion-popover>

编辑:不是您想要的。也许有可能强制CSS中的增长方向,但似乎不是本地属性(我猜是增长“属性”相对于可用的空间而言)。

edit2 https://forum.ionicframework.com/t/popover-open-to-top-top-top-apperaining-creen-screen-on-on-on-bottom-n-bottom-ofm-a-page/219612/

I believe you are looking for something like this.
You can find more about it here: https://ionicframework.com/docs/api/popover#inline-popover

<!-- Show popover above trigger -->
<ion-button id="side-button">Click to open popover</ion-button>
<ion-popover trigger="side-button" side="top">
  <ng-template>
    <ion-content>Popover Content</ion-content>
  </ng-template>
</ion-popover>

EDIT: Not what you were looking for. Maybe it is possible to force the grow direction in css, but it doesn't seems to be a native property (I guess the grow "property" is relative to the space available downward).

EDIT2: https://forum.ionicframework.com/t/popover-open-to-top-appearing-off-screen-on-bottom-of-a-page/219612/

病毒体 2025-02-14 06:32:46

在某些特定情况下(某些特定元素用作触发器),这似乎是一个离子 - 流行的错误。它不正确地理解侧面=“ top”属性...

一个解决方法,是在弹出元件上使用-offset-y CSS属性,并根据自己喜欢的像素将其移动它在屏幕上。

<ion-popover class="myPopover" trigger="side-button" side="top">

CSS

.myPopover {
  --offset-y: -125px;
}

当然可以将125px更改为适合您菜单的任何东西。

This seems to be a bug with ion-popover in some specific cases (some specific elements used as triggers). It doesn't properly understand the side="top" attribute...

A workaround for it, is to use the --offset-y CSS property, on the popover element and move it up by as many pixels as you like so that its on screen.

<ion-popover class="myPopover" trigger="side-button" side="top">

CSS

.myPopover {
  --offset-y: -125px;
}

Of course you can change 125px to whatever suits your menu.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文