Here is the code that I'm using for a simple form. I pretty much copied the entire form from the example on Bootstrap's website, and removed all controls except a text input and the submit button.
<form>
<fieldset>
<legend>About You</legend>
<input class="input-medium" type="text" placeholder="First Name">
<button type="submit" class="btn">Get Started</button>
</fieldset>
</form>
For some reason, the submit button doesn't drop to a new line when it comes right after an input.
You'll see, if I just add the checkbox w/ label back from the example, the submit button drops to a new line as expected.
<form>
<fieldset>
<legend>About You</legend>
<input class="input-medium" type="text" placeholder="First Name">
<label class="checkbox">
<input type="checkbox"> Check me out
</label>
<button type="submit" class="btn">Get Started</button>
</fieldset>
</form>
What am I doing wrong? I'm using the latest bootstrap CSS and JS (2.3.2), loaded from BootstrapCDN.com.
To add line breaks to a textarea, use the addition (+) operator and add the \r\n string at the place where you want to add a line break, e.g. 'line one' + '\r\n' + 'line two' .
There are several ways to prevent line breaks in content. Using is one way, and works fine between words, but using it between an empty element and some text does not have a well-defined effect. The same would apply to the more logical and more accessible approach where you use an image for an icon.
The .form-group class is the easiest way to add some structure to forms. It provides a flexible class that encourages proper grouping of labels, controls, optional help text, and form validation messaging. By default it only applies margin-bottom , but it picks up additional styles in .form-inline as needed.
Both <input>
and <button>
have display: inline-block
. <label>
has display: block
and forces button to be rendered on the next line.
The workaround for displaying button in the next line is simply wrap it in an element with display: block
, i.e. in a <div>
element.
Look at this FIDDLE DEMO
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