I have an example what I want to achieve.
As you can see, there is a little refresh icon inside that pill on the right site that has its own color and background color. I tryed to get something like this with bootstrap but I just can’t set the background to the right size without making the icon element itself way to large for the container.
This is the closest I currently have but that doesn’t look nearly as good as in the example picture. Can this be fixed with better css or are those icon just not good for that purpose?
.buttonContainer {
font-size: large;
}
.badge {
font-weight: 500 !important;
border-color: #adb5bd !important;
}
.icon {
display: inline-block;
border-radius: var(--bs-border-radius-pill) !important;
background-color: lightgray;
color: var(--bs-secondary);
}
.toBig {
padding: 5px;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<div class="buttonContainer">
<p>Background to small</p>
<span class="badge rounded-pill border text-dark">Test test test <i class="bi bi-tools icon"></i></span>
<span class="badge rounded-pill border text-dark">Test test test <i class="bi bi-arrow-repeat icon"></i></span>
</div>
<br/>
<br/>
<div class="buttonContainer">
<p>Background ok but icon itself to big</p>
<span class="badge rounded-pill border text-dark">Test test test <i class="bi bi-tools icon toBig"></i></span>
<span class="badge rounded-pill border text-dark">Test test test <i class="bi bi-arrow-repeat icon toBig"></i></span>
</div>
2
Answers
You should define different styles for each size.