简体   繁体   English

如何为多个离子网格分配不同的高度?

[英]How to assign different height to multiple ion-grid's?

Situation: I have an Ionic/Angular app.情况:我有一个 Ionic/Angular 应用程序。 As you can see in the attached image and Stackblitz, I have a screen consisting of ion-grid 's, one green and another red background color.正如您在附加图像和 Stackblitz 中看到的那样,我有一个由ion-grid组成的屏幕,一种绿色和另一种红色背景色。

Goal: I would like to assign a percentage height to each one, for example: 70% to the green one and the rest 30% to the red one.目标:我想为每个人分配一个百分比高度,例如:70% 给绿色的,其余 30% 给红色的。 This way, the red one part should be able to scroll to be able to read all the text.这样,红色部分应该可以滚动才能阅读所有文本。 This means that the "global" scrollbar shouldn't exist, only in the red area.这意味着“全局”滚动条不应该存在,只存在于红色区域。

在此处输入图片说明

What I have tried: I have tried with different ion-row 's and ion-col 's configurations, even setting the red grid to position:fixed or position:sticky , but I'm not happy with the position of the green grid, which overlaps the red one and I don't know how to put it below (vertically next to) the red one.我尝试过的:我尝试了不同的ion-rowion-col的配置,甚至将红色网格设置为position:fixedposition:sticky ,但我对绿色网格的位置不满意,它与红色重叠,我不知道如何将它放在红色下面(垂直旁边)。

Stackblitz: https://stackblitz.com/edit/ionic-t8maqc Stackblitz: https ://stackblitz.com/edit/ionic-t8maqc

Any help would be really appreciated!任何帮助将非常感激!

You can use an own style for each grid.您可以为每个网格使用自己的样式。

For example, in your html file you can have something like this:例如,在您的 html 文件中,您可以有这样的内容:

<ion-grid class="greenGrid">
    *your code here*
</ion-grid> 
<ion-grid class="redGrid">
    *your code here*
</ion-grid>

And then in the css file for this html file, this code:然后在此 html 文件的 css 文件中,此代码:

.greenGrid {
    background: green;
    height: 70%; 
}

.redGrid {
    background: red;
    height: 30%; 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM