[英]Flex-grow does not work in Angular for <router-outlet>
I create a web application with Angular.我使用 Angular 创建了一个 web 应用程序。 I wanted to make a footer that will be at the bottom of the page.我想制作一个位于页面底部的页脚。 If the content of the page was small, the footer would still be at the bottom, not in the middle of the page.如果页面内容很小,页脚仍然会在底部,而不是在页面中间。 For this, I wrote code to push the contents of the <router-outlet>
directive down the page.为此,我编写了代码将<router-outlet>
指令的内容推送到页面下方。 But unfortunately it doesn't work.但不幸的是,它不起作用。
This my code in css (code from the styles.css file):这是我在 css 中的代码(来自 styles.css 文件的代码):
#portal-wrapper {
min-height: 100%;
display: flex;
flex-direction: column;
align-items: stretch;
}
router-outlet {
flex-grow: 1;
}
app-menu, router-outlet, app-footer {
flex-shrink: 0;
}
This is the content of my app.component.html file:这是我的 app.component.html 文件的内容:
<div id="portal-wrapper">
<app-menu></app-menu>
<div id="portal">
<div class="container">
<router-outlet></router-outlet>
<div class="row">
<app-footer></app-footer>
</div>
</div>
</div>
</div>
Theoretically, the content should be pushed down (more precisely, the empty space below it) so that the footer is at the bottom of the page.理论上,内容应该被下推(更准确地说,是它下面的空白区域),这样页脚就在页面的底部。 flex-grow: 1;
for <app-menu>
works and pushes <router-outlet>
down.对于<app-menu>
起作用并将<router-outlet>
向下推。 Any suggestions why <router-outlet>
doesn't push footer down?有什么建议为什么<router-outlet>
不向下推页脚?
div with portal-wrapper
has two child ie <app-menu>
and div portal
, when make portal-wrapper
into a flexbox you can use flex-grow: 1
only for its child.带有portal-wrapper
div 有两个子元素,即<app-menu>
和 div portal
,当将portal-wrapper
制作成 flexbox 时,您可以仅将flex-grow: 1
用于其子元素。
flex-grow: 1;
for<app-menu>
works and pushes<router-outlet>
down.对于<app-menu>
起作用并将<router-outlet>
向下推。
It's actually pushing the div portal
down and not just the <router-outlet>
它实际上将 div portal
向下推,而不仅仅是<router-outlet>
You should make div container
into flexbox and add flex-grow: 1
to <router-outlet>
.您应该将 div container
放入 flexbox 并将flex-grow: 1
添加到<router-outlet>
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.