ionic-framework - ionic 4 中垂直居中的行

标签 ionic-framework ionic4

我使用的是 Ionic 版本 4,我希望应用程序中的登录表单垂直居中。

我尝试了堆栈溢出中存在的许多解决方案,但看起来都适用于 Ionic 版本 3,还尝试了一些 CSS类似的技巧margin 0 auto;

display:flex;
justify-content:center !important;
align-content:center !important;

但对我不起作用。

enter image description here

这就是我的表单的样子,我另外使用了 bootstrap 并且没有自定义 css添加到模板中的类。

这是我的模板代码。
<ion-content color="light">
  <ion-grid>
    <ion-row class="ion-justify-content-center">
      <ion-col size-xs="9" size-md="9">
        <form>
            <div class="form-group">
              <input
                type="text"
                class="form-control"
                placeholder="Enter AccountID"
                autocomplete="off"
              />
            </div>
            <div class="form-group">
              <input
                type="email"
                class="form-control"
                placeholder="Enter Email"
                autocomplete="off"
              />
            </div>
            <div class="form-group">
              <input
                type="password"
                class="form-control"
                placeholder="Enter Password"
                autocomplete="off"
              />
            </div>
            <button type="submit" class="btn btn-primary btn-block">Submit</button>
        </form>
      </ion-col>
    </ion-row>
  </ion-grid>
</ion-content>

最佳答案

我是用这种风格做到的

ion-grid{
    height: 100%;
}
ion-row{
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

关于ionic-framework - ionic 4 中垂直居中的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56444748/

相关文章:

angular - 键盘覆盖了 ios - Ionic 5 中的输入字段

Cordova -找不到名字 'FirebaseCrashlytics'

css - 无法使表单控件透明

javascript - AngularJS - 充当单选按钮的 3 按钮组

linux - 如何在 Ionic/Capacitor 中设置 Android Studio 的正确路径?

angular - 如何在 ionic v1 中使用 FCM

javascript - 如何在 iOS 中的 Ionic 电容器中打开登录表单的 Web View 自动完成功能?

css - 如何成功自定义 ionic 全局 css 颜色?

html - 如何从ios中的工具栏删除边框?

javascript - 如何使字段在 ionic + Angular 中居中对齐(在中心)