Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 small badge next to big title

I'm trying to get a small Bootstrap (4) badge next to a big title. What i've tried:

<h1>Product <span class="badge badge-primary">Version 1</span></h1>

and

<h1>Product></h1>
<span class="badge badge-primary">Version 1</span

What I want:

What is the easiest way to achieve this?

like image 385
Thomas Wagenaar Avatar asked Sep 25 '17 13:09

Thomas Wagenaar


People also ask

How do I make my bootstrap badge smaller?

Approach 1: Using Inline styling: You can simply add a style attribute to the span tag which has badge-pill as a class and change the font-size according to your wish.

How do you indicate a badge in bootstrap?

To use badges just add <span class = "badge"> to links, Bootstrap navs, and more. When there are no new or unread items, badges will simply collapse via CSS's :empty selector, provided no content exists within.

Which class can be used to change the shape of a badge?

Use the . badge-pill modifier class to make badges more rounded (with a larger border-radius and additional horizontal padding ).


3 Answers

Something like

<div>
  <h1 style="display: inline-block">Product</h1>
  <span class="badge badge-primary" style="vertical-align: top">Version 1</span>
</div>

might do the trick.

like image 130
AKX Avatar answered Oct 11 '22 19:10

AKX


A cleaner approach would be to use the Bootstrap 4 utility classes that have been provided:

<h2 class="h3 d-inline-block">Product</h2>
<span class="badge badge-primary align-top">Version 1</span>

Output

Reading Material

display

vertical-align

like image 23
Orphaned Record Avatar answered Oct 11 '22 19:10

Orphaned Record


You should use the first version:

<h1>Product <span class="badge badge-primary">Version 1</span></h1>

And apply the following styles on .badge

font-size: 10px;
vertical-align: top;
top: 10px; //depends on your font-size
position: relative;
like image 1
eberhapa Avatar answered Oct 11 '22 17:10

eberhapa