Icon vertical alignment and size issues
See original GitHub issueIt appears that the icons, when paced inside dropdowns and butons, is slightly off vertically (baseline is not quite lined up with the font), as well as when icons are placed inline with text.
A fix we have implemented is as follows:
.bi {
vertical-align: -0.125em;
margin-bottom: calc(-0.125em / 2);
}
// Make icons slightly larger (aesthetically) in input group prepend/append
.input-group {
.input-group-text {
.bi {
transform: scale(1.5);
}
}
}
// Make icons slightly larger (aesthetically) in buttons and dropdowns
.btn,
.dropdown {
.bi {
transform: scale(1.5);
// reset the bottom margin from above
margin-bottom: 0;
}
}
Before
After
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Vertical Alignment Bug with Icons
If you have been working with an icon set and noticed that your icons are not vertically centered, then you are not alone....
Read more >Align material icon vertically
I used vertical-align: bottom now, that seems to be better for some reason. I think your suggestion is the best way, hence I...
Read more >vertical-align of the icons is bottom instead of middle
Do you have an idea where to look, it's not from the theme css I think. This part brakes it: element.style { width:...
Read more >15 ways to implement vertical alignment with CSS
Learn 15 ways to implement vertical alignment for text with CSS, such as explicit grid row placement and pseudo-elements on flex containers.
Read more >How to Vertically Align the Text with a Large Font ...
In this snippet, we'll show how you can align the text next to a large Font Awesome icon. For that, use the CSS...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The fix that works for me is moving the icons slightly up, not more down:
Original bootstrap 4.x, no change, using icon font 1.3.x
With
vertical-align: 0.125em;
If you add the class d-flex on a button you can add the class align-items-center to the icon and it will be aligned to the middle