gpt4 book ai didi

html - 当尺寸变得超小时, Bootstrap : Accomplish left-, 表单元素的右边距?

转载 作者:太空宇宙 更新时间:2023-11-04 08:18:03 24 4
gpt4 key购买 nike

我已经制作了这种形式,它在所有大于 xs(特小)的尺寸上表现和看起来都不错。

.row {
margin-bottom: 20px;
}

.row:first-of-type {
margin-top: 40px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-xs-12">
<form action="" method="GET" role="form" class="form-horizontal">
<div class="row">
<legend>Form title</legend>
</div>
<div class="row">
<div class="form-group">
<label for="first-name" class="col-sm-2">Your First Name: </label>
<div class="col-sm-4">
<input type="text" class="form-control" id="first-name" placeholder="Please enter your first name.">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="last-name" class="col-sm-2">Your Last Name: </label>
<div class="col-sm-4">
<input type="text" class="form-control" id="last-name" placeholder="Please enter your last name.">
</div>
</div>
</div>

<div class="row">
<div class="form-group">
<label for="email" class="col-sm-2">Your Email: </label>
<div class="col-sm-8">
<input type="text" class="form-control" id="email" placeholder="Please enter your email adresse.">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="phone" class="col-sm-2">Your Phone Number: </label>
<div class="col-sm-3">
<input type="text" class="form-control" id="phone" placeholder="Please enter your phone number.">
</div>
</div>
</div>
<div class="row">
<button type="submit" class="col-sm-1 btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>

但是当显示变得特别小时,输入和标签会延伸到浏览器窗口的边缘。

On a small scaled window.

我想在左边和右边留一点边距。

我是不是做错了什么?

有没有办法只用 Bootstrap 来解决这个问题?还是我必须添加一些额外的 CSS?

最佳答案

一个非常简单的解决方案。其实是误会。只需将 class="form-horizo​​ntal" 更改为 class="form-vertical" ....

演示:

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-12">
<form action="" method="GET" role="form" class="form-vertical">
<div class="row">
<legend>Form title</legend>
</div>
<div class="row">
<div class="form-group">
<label for="first-name" class="col-sm-2">Your First Name: </label>
<div class="col-sm-4">
<input type="text" class="form-control" id="first-name" placeholder="Please enter your first name.">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="last-name" class="col-sm-2">Your Last Name: </label>
<div class="col-sm-4">
<input type="text" class="form-control" id="last-name" placeholder="Please enter your last name.">
</div>
</div>
</div>

<div class="row">
<div class="form-group">
<label for="email" class="col-sm-2">Your Email: </label>
<div class="col-sm-8">
<input type="text" class="form-control" id="email" placeholder="Please enter your email adresse.">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="phone" class="col-sm-2">Your Phone Number: </label>
<div class="col-sm-3">
<input type="text" class="form-control" id="phone" placeholder="Please enter your phone number.">
</div>
</div>
</div>

<button type="submit" class="col-sm-1 btn btn-primary">Submit</button>

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

关于html - 当尺寸变得超小时, Bootstrap : Accomplish left-, 表单元素的右边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45772241/

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