为了账号安全,请及时绑定邮箱和手机立即绑定

列内容垂直对齐 - Bootstrap 4

列内容垂直对齐 - Bootstrap 4

慕森王 2023-08-21 17:55:53
我正在尝试为用户提交表单时创建一个加载动画,然后通知他们是否成功或是否有错误。我的问题是加载图标和文本没有与其所在的 div 中心垂直对齐(col)。我希望将其放在中间,以便我可以在一段时间后用表单提交的响应替换列内容(加载图标和文本)。我正在使用 Bootstrap 4,并且尝试了各种不同的代码,例如align-items-center和my-auto,但没有成功。<div class="container-fluid h-100 w-100 formSubmitLoad d-flex flex-column" id="loader">    <div class="row justify-content-center align-items-center h-100" id="loadingIcon">        <div class="col-11 col-md-6 text-center bg-primary h-75">            <i class="fas fa-spinner fa-pulse fa-4x"></i>            <h2 class="pt-4">Loading</h2>        </div>        <div class="col-11 col-md-6 text-center bg-primary h-75 d-none">            <!-- Column content to replace above column-->        </div>    </div></div>.formSubmitLoad {  position: fixed;  z-index: 1;  left: 0;  top: 0;  overflow: auto;  color: white;  background-color: rgb(0, 0, 0);  background-color: rgba(0, 0, 0, 0.9);}片段:
查看完整描述

1 回答

?
守候你守候我

TA贡献1802条经验 获得超10个赞

更新您的代码,如下所示:


.formSubmitLoad {

  color: white;

  background-color: rgba(0, 0, 0, 0.9);

}

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" >

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0/css/all.css">

<div class="container-fluid h-100 w-100 formSubmitLoad position-fixed" id="loader">

    <div class="row h-100" id="loadingIcon">

        <div class="m-auto col-11 col-md-6 d-flex flex-column justify-content-center align-items-center bg-primary h-75">

            <i class="fas fa-spinner fa-pulse fa-4x"></i>

            <h2 class="pt-4">Loading</h2>

        </div>


        <div class="m-auto col-11 col-md-6 text-center bg-primary h-75 d-none">

            <!-- Column content to replace above column-->

        </div>

    </div>

</div>


查看完整回答
反对 回复 2023-08-21
  • 1 回答
  • 0 关注
  • 68 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信