Source code of Bootstrap form layout style, bootstrap form

Source: Internet
Author: User

Source code of Bootstrap form layout style, bootstrap form

Bootstrap provides three forms: vertical forms, inline forms, and horizontal forms.
Create a vertical or basic form:
• Add role = "form" to the parent <form> element ".
• Place tags and controls in a <div> with class. form-group. This is required to obtain the optimal spacing.
• Add class. form-control to all text elements <input>, <textarea>, and <select>

Inline form:
All the elements in an inline form are aligned to the left and labels are side by side. To create an inline form, you must add class. form-inline to the form label.

Horizontal form:Unlike the other two forms, follow these steps to create a horizontal form.
• Add class. form-horizontal to the parent <form> element.
• Place tags and controls in a <div> with class. form-group.
• Add class. control-label to the label.

The Bootstrap form layout is as follows:

Implementation Code:

<Form class = "form-horizontal" role = "form"> <fieldset> <legend> Configure the data source </legend> <div class = "form-group"> <label class = "col-sm-2 control-label" for = "ds_host"> host name </label> <div class = "col-sm-4"> <input class = "form-control" id = "ds_host" type = "text" placeholder = "192.168.1.161"/> </div> <label class = "col-sm-2 control-label" for = "ds_name"> database name </label> <div class = "col-sm-4"> <input class = "form-control" id = "ds_name" type = "text" placeholder = "msh"/> </div> <div class = "form-group"> <label class = "col-sm-2 control-label" for = "ds_username"> User Name </label> <div class = "col-sm-4"> <input class = "form-control" id = "ds_username" type = "text" placeholder = "root"/> </div> <label class = "col-sm-2 control-label" = "ds_password"> password </label> <div class = "col-sm-4"> <input class = "form-control" id = "ds_password" type = "password" placeholder =" 123456 "/> </div> </fieldset> <legend> select a table </legend> <div class =" form-group "> <label for = "disabledSelect" class = "col-sm-2 control-label"> table name </label> <div class = "col-sm-10"> <select id = "disabledSelect" class = "form -control "> <option> deselected </option> </select> </div> </fieldset> <fieldset> <legend> Field name </legend> <div class = "form-group"> <label for = "disabledSelect" class = "col-sm-2 control-label"> table name </label> <div class = "col-sm-10"> <select id = "disabledSelect" class = "form-control"> <option> deselected </option> <option> deselected </ option> </select> </div> </fieldset> </form>

If you want to learn more, click here to learn more and add a special topic: Bootstrap learning tutorial.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.