Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buttons run together in Bootstrap 2.0.1

I'm using Bootstrap 2.0.1, and in my pages I often have a couple of buttons next to each other:

<a class="btn btn-primary btn-large x-create-quiz">Create Quiz</a>
<a class="btn x-cancel">Cancel</a></div>

The buttons render next to each other, with no spacing between them.

I've had to add a &nbsp; between the two.

Looking at the source of the Twitter Bootstrap documention, they do the same thing, but get a small space between the buttons.

Any idea why? I'd prefer to eliminate the  . Could there be some enclosing <div> somewhere that provides the gap?

I've gotten the same results in Chrome and FireFox.

like image 346
Howard M. Lewis Ship Avatar asked Mar 13 '12 18:03

Howard M. Lewis Ship


People also ask

How do I put two buttons on the same line in Bootstrap?

Use the . btn-group class in Bootstrap to group buttons on a single like.

How do I make two buttons side by side in Bootstrap?

You can use an out div with a class btn-group . This helps to align the buttons horizontally. Using col-md-6 for each button div can make the buttons missaligned with unwanted space in between.


1 Answers

I had the same issue. I'm using node/express/jade and found that jade will remove any whitespace on delivery by default, resulting in something like this:

<button class="...">reset</button><button class="...">save</button>

Your buttons won't run together if there is whitespace between them. For jade you may explicitly add space via = ' ' between your buttons or choose to enable pretty printing:

app.set('view options', { pretty: true })

Hope this is of help to you, took me some time to realize this behavior...

like image 143
sbange Avatar answered Sep 27 '22 18:09

sbange