gpt4 book ai didi

html - 如何在 Bootstrap 中以表格形式居中输入?

转载 作者:搜寻专家 更新时间:2023-10-31 22:18:04 25 4
gpt4 key购买 nike

我想要两个输入(登录名和密码)。一比一,每个约 col-sm-6。如果没有 col-sm-offset-3,我无法将此输入居中。使用 offset 它确实有效,但我想将此输入集中在每个屏幕上。也许我应该在某个地方添加 .center > 或 margin auto?但是哪里...

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<div class="container">

<div class="row">
<div class="box">
<div class="col-lg-12">
<hr>
<h4 class="text-center">Logowanie</h4>
<hr>
<form method="post" role="form" class="form-horizontal">
{{ csrf_field() }}
<div class="row">
<div class="form-group">
<div class="col-sm-6">
<input type="email" class="form-control" name="email" placeholder="email">
</div>
</div>
<div class="form-group">
<div class="col-sm-6">
<input type="email" class="form-control" name="email" placeholder="email">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>

最佳答案

如果您不想使用 offset,您可以使用一个居中的类,我称之为 .centered 并将其作为您想要居中的内容的包装。

请看下面的例子:

.centered {
display: flex;
align-items: center;
justify-content: center;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">

<div class="row">
<div class="box">
<div class="col-lg-12">
<hr>
<h4 class="text-center">Logowanie</h4>
<hr>
<form method="post" role="form" class="form-horizontal">
{{ csrf_field() }}
<div class="form-group centered">
<div class="col-sm-6">
<input type="email" class="form-control" name="email" placeholder="email">
</div>
</div>
<div class="form-group centered">
<div class="col-sm-6">
<input type="email" class="form-control" name="email" placeholder="email">
</div>
</div>
</form>
</div>
</div>
</div>
</div>

关于html - 如何在 Bootstrap 中以表格形式居中输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43939000/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com