6

I am using bootstrap 4 and I want to create a badge with blue color so I used:

<td><a href="patient_history.php?pid=<?php echo $patient['patient_id']; ?>"><i class="badge badge-info">Edit History</i></a></td>

inside a table of class="table table-hover", and the result was the default badge color and not blue.

enter image description here

alim1990
  • 3,312
  • 9
  • 49
  • 91

4 Answers4

6

use .label-pill instead.

<span class="label label-pill label-primary">Primary</span>

copy the following line in your css and try again

.label-as-badge {
    border-radius: 1em;
}

Your question already seems to have an answer, Try the below link :

how to use .label-pill class in Bootstrap-4

Shivam Arora
  • 435
  • 3
  • 17
  • Just one more question: how can I change the hover color of a table hover class, I tried everything on stack but nothing works – alim1990 Jun 30 '17 at 05:23
  • nope. Where should I add the css code I have 4 css sheets added to my page including the bootstrap – alim1990 Jun 30 '17 at 05:31
3

Try with creating custom classes.

.badge {
  padding: 1px 9px 2px;
  font-size: 12.025px;
  font-weight: bold;
  white-space: nowrap;
  color: #ffffff;
  background-color: #999999;
  -webkit-border-radius: 9px;
  -moz-border-radius: 9px;
  border-radius: 9px;
}

.badge:hover {
  color: #ffffff;
  text-decoration: none;
  cursor: pointer;
}

.badge-error {
  background-color: #b94a48;
}

.badge-error:hover {
  background-color: #953b39;
}

.badge-warning {
  background-color: #f89406;
}

.badge-warning:hover {
  background-color: #c67605;
}

.badge-success {
  background-color: #468847;
}

.badge-success:hover {
  background-color: #356635;
}

.badge-info {
  background-color: #3a87ad;
}

.badge-info:hover {
  background-color: #2d6987;
}

.badge-inverse {
  background-color: #333333;
}

.badge-inverse:hover {
  background-color: #1a1a1a;
}
<span class="badge">1</span>
<span class="badge badge-success">2</span>
<span class="badge badge-warning">4</span>
<span class="badge badge-error">6</span>
<span class="badge badge-info">8</span>
<span class="badge badge-inverse">10</span>
Penny Liu
  • 7,720
  • 5
  • 40
  • 66
Dixit
  • 1,251
  • 3
  • 16
  • 36
3

Use progress-bar instead of badge. For example :

<i class="badge progress-bar-info">Edit History</i>

<span class="badge progress-bar-success">Active</span>
<span class="badge progress-bar-danger">Inactive</span>
1

Use it

Use the .label class, followed by one of the six contextual classes .label-default, .label-primary, .label-success, .label-info, .label-warning or .label-danger, within a <span> element to create a label

 <span class="label label-default">Edit History</span>