Bootstrap4 badge source code
.badge {
display: inline-block;
padding: $badge-padding-y $badge-padding-x;
font-size: $badge-font-size;
font-weight: $badge-font-weight;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
@include border-radius($badge-border-radius);
@include transition($badge-transition);
@at-root a#{&} {
@include hover-focus {
text-decoration: none;
}
}
// Empty badges collapse automatically
&:empty {
display: none;
}
}
vertical-align: baseline;
Check vertical-align in depth
.
@at-root a#{&}
@at-root
means the selector definition is valid outside of .badge
at the root of CSS. a#{&}
= a .badge
.
&:empty
means .badge:empty
and it selects all the empty dadges.