我創建了一個帶有用戶名和密碼輸入的按鈕和超鏈接的登錄頁面。 我想將整個離子含量垂直和水平放置在屏幕中心。將離子內容的內容呈現在IONIC屏幕中央2/3
ion-content {
position: absolute;
top: 50%;
left: 0%;
right: 50%;
margin: 0 auto;
margin-top: 0;
margin-left: 0;
}
// .div1 {
// position: absolute;
// background-color: green;
// top: 0;
// left: 0;
// right: 0;
// bottom: 0;
// display: block;
// width: 100%;
// height: 100%; // contain: layout size style;
// }
// // .Absolute-Center {
// // margin: auto;
// // position: absolute;
// // top: 0; left: 0; bottom: 0; right: 0;
// // }
// div {
// position: absolute;
// top: 0;
// bottom: 0;
// left: 0;
// right: 0;
// margin: auto;
// width: 100%;
// height: 100%;
// background-color: transparent;
// }
<ion-header>
<ion-navbar>
<ion-title>login</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-item>
<ion-label floating>User Name</ion-label>
<ion-input [(ngModel)]="user.username" type="text" style="background-color:transparent"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Password</ion-label>
<ion-input [(ngModel)]="user.password" type="password"></ion-input>
</ion-item>
<button padding (click)="homePage()" color=secondary ion-button full round>Login</button>
<a (click)="registerPage()">New ? Register here</a>
</ion-content>
您能否提供一些其他的方式來實現這一目標。輸出應該非常敏感。
它在屏幕中心水平對齊所有內容.Flex方向應該是我的場景中的列類型 –
哦,沒錯,在我的結尾,我擁有了表單中的所有內容。我已經用你的評論更新了答案。 – sebaferreras
其對齊到屏幕頂部..不居中。 –