question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Icon vertical alignment and size issues

See original GitHub issue

It 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

image

image

image

image

After

image

image

image

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mariusacommented, Jan 20, 2021

The fix that works for me is moving the icons slightly up, not more down:

 vertical-align: 0.125em;

Original bootstrap 4.x, no change, using icon font 1.3.x Screenshot from 2021-01-20 17-37-20

With vertical-align: 0.125em; Screenshot from 2021-01-20 17-37-27

1reaction
passanantegcommented, Aug 15, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found