简体   繁体   中英

align-items-center is not working on Ionic4

I have this structure in an HTML of my Ionic 4 project:

<ion-header  ....
<ion-content ....

<ion-footer>
  <ion-toolbar color="dark">
    <ion-row align-items-center no-padding>
      <ion-col size="10">
        <textarea  autosize maxRows="3" [(ngModel)]="newMsg" class="message-input"></textarea>
      </ion-col>
      <ion-col size="2">
        <ion-button expand="block" fill="clear" color="primary"
         (click)="sendMessage()">
         <ion-icon name="send" slot="icon-only"></ion-icon>
        </ion-button>
      </ion-col>
    </ion-row>
  </ion-toolbar>
</ion-footer>

在此处输入图片说明

However, as you can see, the object is not vertically centered inside the column. What could be wrong?

.scss file:

#container {
  text-align: center;
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

#container strong {
  font-size: 20px;
  line-height: 26px;
}

#container p {
  font-size: 16px;
  line-height: 22px;

  color: #8c8c8c;

  margin: 0;
}

#container a {
  text-decoration: none;
}

ion-content ion-toolbar {
  --background: translucent;
}

.message {
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 4px;
  white-space: pre-wrap;
}

.other-message {
  background: var(--ion-color-tertiary);
  color: #fff;
}

.my-message {
  background: var(--ion-color-secondary);
  color: #fff;
}

.time {
  color: #dfdfdf;
  float: right;
  font-size: small;
}

.message-input {
  width: 100%;
  border: 1px solid var(--ion-color-medium);
  border-radius: 10px;
  background: #fff;
  resize: none;
  padding-left: 10px;
  padding-right: 10px;
}

.msg-btn {
  --padding-start: 0.5em;
  --padding-end: 1em;
}

Here is implementation: https://stackblitz.com/edit/ionic-4-angular-8-start-template-1icwlg

Ionic 4 should give you warnings that instead of attributes for both align and padding, relevant ion css classes should be used instead:

<ion-row class="ion-align-items-center ion-no-padding"></ion-row>

Can you try this?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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