I can't figure out what controls the margins between these inline form elements. For example the margin between the two text input fields.
EDIT: I know how to control to alter these margins, but why is there a margin between them AT THE MOMENT. I can't find any CSS in bootstrap that is responsible for these 3 or 4px margins between them at the moment.
Bootstrap form-control class is use to make an element fit it container <div> <input type='text' class='form-control'> </div> div{ width: 400px; background: gray; }
The margin-right CSS property sets the margin area on the right side of an element. A positive value places it farther from its neighbors, while a negative value places it closer.
A horizontal form means that the labels are aligned next to the input field (horizontal) on large and medium screens. On small screens (767px and below), it will transform to a vertical form (labels are placed on top of each input). Additional rules for a horizontal form: Add class .
The space between the inputs on Bootstrap's documentation is due to white space in the HTML. Remember that .form-group
is set to inline block, which is sensitive to white space.
For a demonstration, see http://jsfiddle.net/kvcrawford/Rs54Q/1/
You can fix it with some CSS like the following:
.form-inline-space-fix .form-group {
margin-right: 4px;
}
.form-inline-space-fix .form-group:last-child {
margin-right: 0;
}
Here are the CSS selectors you will need..
Margin the inputs/fields:
.form-inline .form-group {
margin: 0px 10px; /* Add something like this */
}
Margin for the checkbox/radio button:
.form-inline .radio, .form-inline .checkbox {
margin: 0px 10px; /* Add something like this */
}
Margin for the submit button:
.bs-example > .btn, .bs-example > .btn-group {
margin: 0px 10px; /* Add something like this */
}
Margin for the entire inline form
.bs-example {
margin: 0px 30px; /* Add something like this */
}
And to answer your question, there are currently margins between elements, because that is the default. If you wish to remove them, I would suggest doing this manually by adding negative margins to the CSS controls I specified above. For instance, if you wish to remove the margins between the inputs, do this:
.form-inline .form-group {
margin: 0px -3px; /* Add a negative margin to remove it*/
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With