gpt4 book ai didi

css - Bootstrap Checkbox 未与标签对齐,在移动设备上更糟

转载 作者:太空宇宙 更新时间:2023-11-04 06:32:44 26 4
gpt4 key购买 nike

我无法获取控制标签来排列复选框输入。在手机上更糟。我希望文本对齐。我究竟做错了什么?我以为缺少一个 div 或其他东西,但它适用于任何其他输入。我尝试使用 css 调整边距,但现在两者都可以。任何帮助,将不胜感激。这是代码:

   
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login</title>


<style>
form .line {
margin-bottom: 5px;
}
p{
margin-top: 20px;
}

</style>


<div class="container">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">


<div class="panel panel-default">
<div class="panel-body">
<form class="form-horizontal">
<fieldset>

<!-- Form Name -->
<legend>Login</legend>







<!-- Text input-->
<div class="form-group line">
<label class="col-md-4 control-label" for="identity">Username</label>
<div class="col-md-4">
<input id="identity" name="identity" type="text" placeholder="Enter Username" class="form-control input-md">

</div>
</div>

<!-- Password input-->
<div class="form-group line">
<label class="col-md-4 control-label" for="password">Password</label>
<div class="col-md-4">
<input id="password" name="password" type="password" placeholder="Enter Password" class="form-control input-md">

</div>
</div>

<!-- Multiple Checkboxes (inline) -->
<div class="form-group">
<label class="col-md-4 control-label" for="remember">Remember Me</label>
<div class="col-md-4">
<label class="checkbox-inline" for="remember">
<input type="checkbox" name="remember" id="remember" value="1">

</label>
</div>
</div>

<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-4">
<button id="submit" name="submit" class="btn btn-primary">Login</button>
<p><a href="forgot_password"><!--?php echo lang('login_forgot_password');?--></a></p>
</div>
</div>

</fieldset>
</form>
</div>



</div>

</div>


</div>
<div class="col-md-2"></div></div>


<div id="push"></div>

最佳答案

你可以添加一些CSS样式来控制.checkbox-inline的位置

媒体查询将为较小的屏幕移动复选框。

另请注意,我将类 .form-small 添加到您的最后一个 .form-group 以控制复选框在较小屏幕上的位置。

.checkbox-inline {
top: -7px;
}

@media only screen and (max-width: 991px) {
.checkbox-inline {
top: -40px;
right: -115px;
}
.form-small {
margin-bottom: 0 !important;
max-height: 20px;
}
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login</title>


<style>
form .line {
margin-bottom: 5px;
}
p{
margin-top: 20px;
}

</style>


<div class="container">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">


<div class="panel panel-default">
<div class="panel-body">
<form class="form-horizontal">
<fieldset>

<!-- Form Name -->
<legend>Login</legend>







<!-- Text input-->
<div class="form-group line">
<label class="col-md-4 control-label" for="identity">Username</label>
<div class="col-md-4">
<input id="identity" name="identity" type="text" placeholder="Enter Username" class="form-control input-md">

</div>
</div>

<!-- Password input-->
<div class="form-group line">
<label class="col-md-4 control-label" for="password">Password</label>
<div class="col-md-4">
<input id="password" name="password" type="password" placeholder="Enter Password" class="form-control input-md">

</div>
</div>

<!-- Multiple Checkboxes (inline) -->
<div class="form-group form-small">
<label class="col-md-4 control-label" for="remember">Remember Me</label>
<div class="col-md-4">
<label class="checkbox-inline" for="remember">
<input type="checkbox" name="remember" id="remember" value="1">

</label>
</div>
</div>

<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-4">
<button id="submit" name="submit" class="btn btn-primary">Login</button>
<p><a href="forgot_password"><!--?php echo lang('login_forgot_password');?--></a></p>
</div>
</div>

</fieldset>
</form>
</div>



</div>

</div>


</div>
<div class="col-md-2"></div></div>


<div id="push"></div>

关于css - Bootstrap Checkbox 未与标签对齐,在移动设备上更糟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54506901/

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