gpt4 book ai didi

angular - 如何在 Angular Material 4 中居中对齐卡片?

转载 作者:太空狗 更新时间:2023-10-29 17:29:33 25 4
gpt4 key购买 nike

我创建了一个带有 Angular Material 的示例 Angular 4 应用程序。我正在尝试将卡片置于 View 中心。但它不起作用。下面是代码

app.component.html

<!--The content below is only a placeholder and can be replaced.-->
<router-outlet></router-outlet>

login.component.html

<div  ng-cloak=""  layout-fill layout="column" style="background:green" layout-align="center">
<div flex="50" layout="row" layout-align="center">
<md-card flex="50"></md-card>
</div>
</div>

login.component.ts

import { Component, OnInit } from '@angular/core';
import { MdCardModule,MdInputModule } from '@angular/material';

@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}

最佳答案

md-card 添加一个类,如下所示:

.center{
width: 75%;
margin: 10px auto;
}

.main-div{
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}

html:

<div class="main-div">
<md-card class="z-depth center" flex="50" >Simple card</md-card>
</div>

demo

关于angular - 如何在 Angular Material 4 中居中对齐卡片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45212473/

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