Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 badge is not changing color

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

like image 401
alim1990 Avatar asked Jun 30 '17 05:06

alim1990


People also ask

How do I change my badge background color?

Color shading Create custom badge with custom background color by using bg-{darken|lighten}-* shading class, . bg-alpha-* to change the background alpha channel and . text-{color} to set the font color.

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

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

like image 72
Shivam Arora Avatar answered Dec 03 '22 00:12

Shivam Arora


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>
like image 35
Darien Daud Avatar answered Dec 03 '22 00:12

Darien Daud


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>
like image 41
Dixit Avatar answered Dec 02 '22 23:12

Dixit