html - Bootstrap 4.1 中以横向为中心的垂直对齐问题
问题描述
在横向中,我的垂直对齐集中(屏幕中央的卡片)有问题,它会剪切各种信息,例如我的图像(徽标)...
“问题”出h-100
在MAIN 标签、CONTAINER和ROW中。
但是我不知道为什么会出现这种方向的问题,因为我正在关注引导文档,我知道解决此问题的唯一方法是使用@media queries,但这会“错误”笔记本的其他分辨率和电脑。..
我应该怎么做,为什么会出现这个问题?
CSS:
html,
body { height: 100%; }
HTML:
<main class="h-100">
<div class="container h-100">
<div class="row justify-content-center align-items-center h-100">
<div class="col-12">
<div class="card mx-auto d-block shadow-md-large w-md-80 w-lg-50">
<div class="card-header bg-transparent border-0 py-md-5">
<img src="/img/logo/aliansce_full.svg" alt="Aliansce Shopping Centers" class="CLI img-fluid mx-auto d-block" autocomplete="on" autofocus require>
</div>
<div class="card-body px-md-5">
<form autocomplete="on">
<div class="form-group EGLF mt-4 mt-md-0">
<input type="text" id="FLUI" class="form-control FI EFLI border-top-0 border-right-0 border-left-0 rounded-0 shadow-none" autocomplete="on" autofocus required>
<!-- FLOAT LABEL EFFECT -->
<label fo="FLUI" id="FLUL" class="EFL">Usuário</label>
<span class="EFHL"></span>
<span class="EFBL"></span>
<!-- FRONTEND RESPONSE ERROR MESSAGE -->
<div id="FBMEU" class="FBMEU ml-1 text-danger"></div>
</div>
<div class="form-group EGLF mt-4">
<input type="password" id="FLUPI" class="form-control FI EFLI border-top-0 border-right-0 border-left-0 rounded-0 shadow-none" min="1" maxlength="10" required>
<!-- FLOAT LABEL EFFECT -->
<label for="FLUPI" id="FLUPL" class="EFL">Senha</label>
<span class="EFHL"></span>
<span class="EFBL"></span>
<!-- FRONTEND RESPONSE ERROR MESSAGE -->
<div id="FBMEUP" class="ml-1 text-danger"></div>
</div>
<div class="form-group mt-5">
<button type="button" id="FBSL" class="btn btn-primary w-esm-100 mb-2 px-lg-5">LOGIN</button>
<button type="button" class="btn bg-light w-esm-100 px-lg-5">VOLTAR</button>
</div>
</form>
<!-- BACKEND RESPONSE ERROR MESSAGE -->
<div class="text-center text-danger">
Usuário ou senha incorretos.
<br> Caso esteja com dificuldades, clique em "Precisa de Ajuda?".
</div>
</div>
<div class="card-footer bg-white border-0">
<button type="button" class="btn btn-link mx-auto d-block">Precisa de Ajuda?</button>
</div>
</div>
</div>
</div>
</div>
</main>
解决方案
我假设您想将卡对齐在两个轴的中心。如果是这样,这可能会解决您的问题。
没有必要使用网格布局,因为您只有一个card
. 此外,您最好不要更改display
. card
就这样吧。
main
在元素
上使用以下类 d-flex
flex-column
改变其方向,使其内容保持其内在属性,例如width
.- 由于它的方向是 now
column
,使用它来垂直居中justify-content-center
对齐它的内容。否则,您将使用.align-items-center
添加一个新d-flex
元素并在其上使用以在中心水平justify-content-center
对齐其内容。
添加另一个block
元素并w-md-80 w-lg-50
在其上使用。
推荐阅读
- html - 滑入式菜单的 CSS onclick 事件(无 JS)
- elasticsearch - Elastalert 在一个文件中简化了多个规则
- c++ - 将犰狳与 MKL 一起使用
- javascript - 通过 $.getJSON 从 JSON 中呈现带有选定键的表
- azure-functions - 如何在 Azure 函数中将连接字符串与 EntityFrameworkCore 3 一起使用
- c++ - ofstream::close() 在 linux 上调用同步吗?
- outlook - 为什么我的 GSuite 在我的 Gmail 中添加为 Microsoft Business Basic 帐户后没有收到电子邮件
- python - 比较数组的索引
- excel - 无法引用工作表上的列表框
- php - PHP测验问题计算单选和复选框