Previous words
<p> Form is a web control used to communicate with users. Good form design can allow web pages to communicate better with users. Common elements in forms mainly include: text input boxes, drop-down selection boxes, radio buttons, check buttons, text fields and buttons, etc. Each control plays a different role, and different browsers have different rendering styles for form controls.
<p> Similarly, forms are also the core content in the Bootstrap framework. This article will introduce Bootstrap’s forms in detail
Basic forms
<p> For the basic forms, Bootstrap has not done much with them. The customized effect design only customized the fieldset, legend, and label tags in the form
fieldset
{ min-width: 0; padding: 0; margin: 0; border: 0;
}legend
{ display: block; width: 100%; padding: 0; margin-bottom: 20px; font-size: 21px; line-height: inherit; color: #333; border: 0; border-bottom: 1px solid #e5e5e5;
}label
{ display: inline-block; margin-bottom: 5px; font-weight: bold;
}
Copy after login
<p> Mainly detailed settings for the margin, padding, and border of these elements
<p> Of course, in addition to these elements, the form also has input, select, textarea and other elements. In the Bootstrap framework, a class name `form-control` is customized. That is to say, if these The element uses the class name "form-control", which will achieve some design customization effects
<p> 1. The width becomes 100%
<p> 2. A light gray color is set (#ccc ) border
<p> 3. With 4px rounded corners
<p> 4. Set the shadow effect, and when the element gets focus, the shadow and border effects will change
<p> 5 , set the placeholder color to #999
<form>
<div class="form-group"><label for="exampleInputEmail1">Email address</label><input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
</div>
<div class="form-group"><label for="exampleInputPassword1">Password</label><input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group"><label for="exampleInputFile">File input</label><input type="file" id="exampleInputFile"><p class="help-block">Example block-level help text here.</p>
</div>
<div class="checkbox"><label> <input type="checkbox"> Check me out</label>
</div>
<button type="submit" class="btn btn-default">Submit</button></form>
Copy after login
horizontal form
<p> The default form of the Bootstrap framework is a vertical display style, but many times we need a horizontal form style
<p> By adding the
.form-horizontal
class to the form and using Bootstrap's preset grid class,
label
labels and control groups can be laid out horizontally side by side. Doing so will change the behavior of
.form-group
so that it behaves like a row in a grid system, so there is no need to add an additional
.row
<p> Using the class name "form-horizontal" on the