Movatterモバイル変換


[0]ホーム

URL:


Menu
×
See More 
Sign In
+1 Get Certified Upgrade For Teachers Spaces Get Certified Upgrade For Teachers Spaces
   ❮     
     ❯   

BootstrapCSS Forms Reference


Bootstrap's Default Settings

Individual form controls automatically receive some global styling with Bootstrap.

All textual <input>, <textarea>,and <select> elements with class="form-control" are set to width: 100%; by default.

Standard rules for all three form layouts:

  • Wrap labels and form controls in<div class="form-group"> (needed for optimum spacing)
  • Add class.form-control to all textual<input>,<textarea>, and<select> elements

The following example creates a simple Bootstrap form with two input fields, one checkbox, and a submit button:

Bootstrap Form Example

<form>
  <div class="form-group">
    <label for="email">Email address:</label>
    <input type="email" class="form-control" id="email">
  </div>
  <div class="form-group">
    <label for="pwd">Password:</label>
    <input type="password" class="form-control" id="pwd">
  </div>
  <div class="checkbox">
    <label><input type="checkbox"> Remember me</label>
  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>
Try it Yourself »

Form Classes

ClassDescriptionExample
.form-inlineMakes a <form> left-aligned with inline-block controls (This only applies to forms within viewports that are at least 768px wide)Try it
.form-horizontalAligns labels and groups of form controls in a horizontal layoutTry it
.form-controlUsed on input, textarea, and select elements to span the entire width of the page and make them responsiveTry it
.form-control-feedbackForm validation classTry it
.form-control-staticAdds plain text next to a form label within a horizontal formTry it
.form-groupContainer for form input and labelTry it

Input Classes

ClassDescriptionExample
.input-groupContainer to enhance an input by adding an icon, text or a button in front or behind it as a "help text"Try it
.input-group-lgLarge input groupTry it
.input-group-smSmall input groupTry it
.input-group-addonTogether with the .input-group class, this class makes it possible to add an icon or help text next to the input fieldTry it
.input-group-btnTogether with the .input-group class, this class attaches a button next to an input. Often used as a search barTry it
.input-lgLarge input fieldTry it
.input-smSmall input fieldTry it


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted ourterms of use,cookies andprivacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.


[8]ページ先頭

©2009-2025 Movatter.jp