I'm using bootstrap-icons, which does not yet have an "unsorted" icon like this:
So I'd like to stack two separate icons to achieve that effect:
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" rel="stylesheet">
<span class="d-inline-block position-relative" style="height: 1rem; width: 1rem;">
<i class="bi bi-caret-up position-absolute" style="font-size: 1rem; top: -5px;"></i>
<i class="bi bi-caret-down position-absolute" style="font-size: 1rem; top: 5px;"></i>
</span>
Run that code snippet, and open it in your browser's devtools - you'll notice the parent wrapper does not properly fit the contents. The parent <span> is smaller than the individual <i> icons. So when used in a table header cell (and other places too), it sometimes looks weird.
How could I fix this?
I have fiddled with your code and learned that:
span(class.unsorted) has to clip excess character spacing withoverflow: hiddenline-heightis already set to1by bootstrap for icons.vertical-align: -0.125remcausing a slight shift up. I circumvented this by making the icons (<i>)display: grid, which also positions the characters nicely inside.unsorted.27.35%.Additionally I introduced a few CSS custom properties to test various sizes of the combined character:
sm, md, xl.I know too little of bootstrap to be any use with that, so I created a vanilla CSS solution that seems to work with your bootstrap code.
snippet