Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 buttons example: where does the space between buttons is coming from? [duplicate]

I have tried to inspect a "Buttons" example from Bootstrap 4. They have a nice-looking row of buttons, like this:

enter image description here

http://getbootstrap.com/docs/4.0/components/buttons/

But I don't understand, where does the space between buttons is coming from.

enter image description here

This is not margin, not flex-box aligning, not a transparent border. So, how it works? Actually, I disabled all the styles in dev-tools, but that space did not disappear.

like image 421
azaviruha Avatar asked Jan 24 '18 05:01

azaviruha


People also ask

How do I remove the space between buttons?

Browsers always add spaces between some elements, including buttons. To remove these, you need to set font-size to zero for their parent container. Then, to restore text size inside buttons, set font-size for them. Works like a charm!

How can Bootstrap show two buttons on same line?

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

How do I put a space in a button in Bootstrap?

To create a toolbar, wrap more button groups into a . btn-toolbar . No spacing is added automatically between the button groups. To add some spacing to your toolbar, use Bootstrap spacing utilities.


1 Answers

The space is there because there's whitespace between the HTML elements. If you remove the whitespace, the buttons will be positioned next to each other.

Note that whitespace (newline) between the elements is condensed to a single space by the browser.

<button type="button" class="btn btn-primary">Primary</button> <button type="button" class="btn btn-secondary">Secondary</button> Buttons with spacing between them

Now if we remove the whitespace:

<button type="button" class="btn btn-primary">Primary</button><button type="button" class="btn btn-secondary">Secondary</button>

enter image description here

like image 96
Colin Miller Avatar answered Oct 05 '22 23:10

Colin Miller