Riferimento ai moduli CSS di Bootstrap
Impostazioni predefinite di Bootstrap
I controlli dei moduli individuali ricevono automaticamente uno stile globale con Bootstrap.
Tutti gli elementi testuali <input>, <textarea> e <select> con class="form-control" sono impostati su width: 100%; per impostazione predefinita.
Regole standard per tutti e tre i layout dei moduli:
- Avvolgi le etichette e i controlli dei moduli
<div class="form-group">
(necessari per una spaziatura ottimale) - Aggiungi classe a tutti gli elementi
.form-control
testuali<input>
,<textarea>
e<select>
L'esempio seguente crea un semplice modulo Bootstrap con due campi di input, una casella di controllo e un pulsante di invio:
Esempio di modulo Bootstrap
<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>
Classi di modulo
Class | Description | Example |
---|---|---|
.form-inline | Makes a <form> left-aligned with inline-block controls (This only applies to forms within viewports that are at least 768px wide) | |
.form-horizontal | Aligns labels and groups of form controls in a horizontal layout | |
.form-control | Used on input, textarea, and select elements to span the entire width of the page and make them responsive | |
.form-control-feedback | Form validation class | |
.form-control-static | Adds plain text next to a form label within a horizontal form | |
.form-group | Container for form input and label |
Classi di ingresso
Class | Description | Example |
---|---|---|
.input-group | Container to enhance an input by adding an icon, text or a button in front or behind it as a "help text" | |
.input-group-lg | Large input group | |
.input-group-sm | Small input group | |
.input-group-addon | Together with the .input-group class, this class makes it possible to add an icon or help text next to the input field | |
.input-group-btn | Together with the .input-group class, this class attaches a button next to an input. Often used as a search bar | |
.input-lg | Large input field | |
.input-sm | Small input field |