gpt4 book ai didi

html - ionic 页脚粘在 ion-content 和屏幕底部

转载 作者:可可西里 更新时间:2023-11-01 13:45:18 26 4
gpt4 key购买 nike

我想制作 ion-footer,高度将取决于内容高度,就像那样

how should it works

此外,页脚不能小于 2 图片(最小高度)。

内容是动态生成的(ion-list *ngFor)。这是我当前的伪代码

<ion-header>
<ion-navbar>
<ion-title>
Title
</ion-title>
</ion-navbar>
</ion-header>

<ion-content padding>
<ion-list>
<button ion-item *ngFor="let item of items">
{{ item.name}}
</button>
</ion-list>
</ion-content>

<ion-footer class="footer">
</ion-footer>

CSS:

.footer{
background-color: blue;
min-height: 10em;
height: auto;
}

但它永远不会填满屏幕上的所有空白区域,我仍然有这样的情况:

how it works

最佳答案

ion-footer 方法在这里不起作用,因为 ion-footer CSS 样式具有绝对定位。这意味着它的高度不能与 ion-content 高度相关。

所需的布局可以通过使用 flex 的不同方法来实现。

<ion-content >
<div style=" display: flex;flex-direction: column;height: 100%;">
<ion-list padding-horizontal padding-top style="overflow-y: scroll;max-height: 90%;">
<button ion-item *ngFor="let item of items">
{{ item.name}}
</button>
</ion-list>
<div style="flex: 1;background-color: blue;">Footer</div>
</div>
</ion-content>

从 HTML 中移除 ion-footer 元素。这应该会给出类似的布局。

关于html - ionic 页脚粘在 ion-content 和屏幕底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45176415/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com