gpt4 book ai didi

html - 如何在 bootstrap 4 中居中选项卡?

转载 作者:行者123 更新时间:2023-11-28 00:41:31 24 4
gpt4 key购买 nike

我想在页面中间显示我的 login/Signup 选项卡及其相关形式,还想将 col-md-12 之类的小文本文件缩小到 col-md-4 但当我使用 style="margin-left=200px;" 时,表单将位于中间但在移动模式下它不显示所以我删除了style="margin-left=200px;"

html,
body {
height: 100%;
}

body {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
padding-top: 40px;
padding-bottom: 40px;
background-color: #f5f5f5;
}

.form-signin {
width: 100%;
max-width: 330px;
padding: 15px;
margin: auto;
}

.form-signin .checkbox {
font-weight: 400;
}

.form-signin .form-control {
position: relative;
box-sizing: border-box;
height: auto;
padding: 10px;
font-size: 16px;
}

.form-signin .form-control:focus {
z-index: 2;
}

.form-signin input[type="email"] {
margin-bottom: -1px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}

.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<div class="container">
<br>
<h4 class="text-center">User Panel</h4>
<hr>
<!-- Nav tabs -->
<ul class="nav nav-tabs form-signin" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#home">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#menu2">SignUp</a>
</li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
<div id="home" class="container tab-pane active"><br>
<form class="form-signin">
<img class="mb-4" src="https://camu.in/assets/img/avatar1.svg" alt="" width="72" height="72">
<h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">&copy; 2017-2018</p>
</form>
</div>

<div id="menu2" class="container tab-pane fade"><br>
<p>Signup</p>
<form class="form-signin">
<img class="mb-4" src="https://camu.in/assets/img/avatar1.svg" alt="" width="72" height="72">
<h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">&copy; 2017-2018</p>
</form>
</div>
</div>


</div>

我想在下面输出页面中间的选项卡和表单,但我做不到。请检查下图我想要什么。此外,当我点击 SignUp 时,一切都变得一团糟。

enter image description here

最佳答案

以类名 nav-tabs 居中 ul通过添加类名 justify-content-center .此外,通过添加类名 pb-0 来触摸事件选项卡和灰色边框到 nav-tabs .

所以,它是<ul class="nav nav-tabs form-signin justify-content-center pb-0" role="tablist">而不是 <ul class="nav nav-tabs form-signin" role="tablist"> .

html,
body {
height: 100%;
}

body {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
padding-top: 40px;
padding-bottom: 40px;
background-color: #f5f5f5;
}

.form-signin {
width: 100%;
max-width: 330px;
padding: 15px;
margin: auto;
}

.form-signin .checkbox {
font-weight: 400;
}

.form-signin .form-control {
position: relative;
box-sizing: border-box;
height: auto;
padding: 10px;
font-size: 16px;
}

.form-signin .form-control:focus {
z-index: 2;
}

.form-signin input[type="email"] {
margin-bottom: -1px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}

.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<div class="container">
<h4 class="text-center">User Panel</h4>
<!-- Nav tabs -->
<ul class="nav nav-tabs form-signin justify-content-center pb-0" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#home">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#menu2">SignUp</a>
</li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
<div id="home" class="container tab-pane active"><br>
<form class="form-signin">
<img class="mb-4" src="https://camu.in/assets/img/avatar1.svg" alt="" width="72" height="72">
<h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">&copy; 2017-2018</p>
</form>
</div>

<div id="menu2" class="container tab-pane fade"><br>
<form class="form-signin">
<img class="mb-4" src="https://camu.in/assets/img/avatar1.svg" alt="" width="72" height="72">
<h1 class="h3 mb-3 font-weight-normal">Please sign up</h1>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">&copy; 2017-2018</p>
</form>
</div>
</div>


</div>

关于html - 如何在 bootstrap 4 中居中选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53241102/

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