-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Material Icons - Vertical Align Doesn't work well alongside text #206
Comments
This sounds more like a CSS issue. Make sure the line-height are the same for both, and set the display to "inline" or "inline-block", and set "vertical-align: middle" See if that works. |
I had the same issue and was able to fix it by using the following CSS code
|
@chicagosky has the right idea. Write CSS that works for your use case. |
Solved it with : |
I used the solution provided by @sylvainar, and still needed to add
Interestingly enough, I tried to put the adjacent text in a div and add padding to the div instead of the icon. Surprisingly, it added padding to both the icon and the div. That seems broken to me as the icon is outside of the div. I'm using Zurb Foundation 5.5.
|
it's kinda crazy but in my experience, having |
Following worked for me:
|
same problem here, for some reasons I solved using:
|
Anybody here could explain why |
Same here, sometimes it works with Strange thing is that in those contexts I have no problems with font awesome |
Hi, thanks. It worked for me |
@chicagosky solution cover most scenarios A general solution could be to always wrap your icons and text so they can be aligned using flexbox
Note that putting "My Text" inside another element is important as well. You also can change |
There's also another option for |
So I've come across this problem quite a bit. I have created a generalised solution which seems to work for the material icons in a number of different situations:
|
Neither solutions worked for me :-/ |
|
This "issue" appears to depend on how your baseline is set up. I usually rely on a 1em body font size with a 1.5 line-height, so this works best in my case:
|
I'll give it a try @simplethemes |
This fix the problem for me: |
@chicagosky thank you, your solution work perfectly!! I can relax my head instead of :D :D |
One more solution, copied at Google.
|
|
While we can "fix" this issue using CSS, I still think that the icon-font baseline should be properly set, and that is a bug. |
Fixed by using below css |
Material icon aligns well with text on desktop browsers but not with android webview on 4.4/5.1 fixed with |
fixed with: i.material-icons {display: inline-flex; vertical-align: top; line-height: inherit;} |
This worked for me: |
@jmc265 solution worked for me |
For those coming to this at the 11th hour, i.e. future me, add a left or right to the element class, e.g. class="material-icons left", and it'll float properly. |
I do not have any "left" class. Can you explain whats inside this CSS Class? |
My apologies. I thought you were using these in conjunction with
materialize-css
…On Mon, Oct 8, 2018 at 02:30 Tobias Zanke ***@***.***> wrote:
I do not have any "left" class. Can you explain whats inside this CSS
Class?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#206 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOsvBj8feUVIO5FoXPXa6Yq9KaFhCTZks5uiv8BgaJpZM4F28Eq>
.
|
|
Worked for me
|
Many thanks. This worked for me.
|
I'm still very lost at how to fix, here is reproduction: https://codepen.io/theaemarie/pen/ROvajg?editors=1100 EDIT: seems to just be a windows 7 problem :/ |
Just switch to Iconify (see #71, and https://iconify.design/) and forget about this nonsense forever :) |
I'm voting for this one:
While other solutions somewhat helped, still when I inspected it in Chrome, I saw that the font symbol is not exactly vertically centered with my other letters when testing with different font sizes. The approach above worked acceptably fine with different font sizes of the text around the icon - the icon is always vertically centered, if that's what you want. I created the additional style to avoid breaking Angular Material components that are using
|
…lete names by using advice from google/material-design-icons#206
This is embarrassingly bad. Most of the solutions in here include a bunch of flexbox rules that are doing nothing, or require wrapping the icon in another div that will undo the alignment-flaw in the original font.
🗑 |
|
This worked! \m/ Thank you @Javid-Izadfar.... |
[SOLUTION] - I just switched from font-awesome, this fixes the vertical issue perfectly, simply apply this styling to your icons font-size: inherit; |
.container display:flex |
Geez, people! It's obviously something terribly wrong here if completely different and contradicting solutions work in different cases! All kinds of Of course it can be worked around with a CSS fix for each icon size, but this is going to break anyway. I fixed all icons alignments in my app, changed DPI setting on my OS settings and it broke immediately. I expect it will look different and wrong on different devices, depending on resolution, DPI settings and god knows what else. This is exactly opposite to what I as user wanted to achieve: I wanted QUICK and EASY way to get app icons, that will work on may devices and display settings. I already lost a couple of days on fighting with the CSS, ending up with getting rid of that icon pack, because despite the very professional look - the vertical alignment of said icons just CANNOT be done right. I also aim at minimalistic CSS, and ended up with HUGE CSS fixing the icons in countless places. That does it, material icons as web font are broken. |
In my case, I changed my CSS like: |
Depends on the size of the mat-icon. Inspect the height of the mat-icon, then add a line-height equal to it { |
For whom, who tried everything, but didn't work any of the top solution as at my side, give a try to: |
This is a deal breaker for me, I really don't want to fight my fonts every time I use them not sure why this is closed. |
THIS WORKED FOR ME. |
Well, if you don't need many sizes in the app, or not many versions (mobile, desktop, etc) - they are still usable. But I agree - when they are a couple of sizes - the problem with vertical alignment is too much working around. There were many regular text web fonts that I was unable to use for the same reason. Original system fonts have no problem with vertical alignment, it just works in every browser, any text size and DPI settings, some of them get this wrong and it breaks. |
Yeah Angular is a pretty good framework. But I quite often run into small but infuriating issues like this. It happens enough to make me refer to Angular as a 'good but certainly not great' framework. |
To anyone visiting this in future: |
Emojis don't always support screen readers in the way you intend. They have alt codes but typically these do not align with the way we use them. They have their use but in accessible web design the span approach is preferred because you can easily disable in aria.
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: xtance ***@***.***>
Sent: Saturday, January 15, 2022 9:51:56 AM
To: google/material-design-icons ***@***.***>
Cc: Dave Southard ***@***.***>; Comment ***@***.***>
Subject: Re: [google/material-design-icons] Material Icons - Vertical Align Doesn't work well alongside text (#206)
To anyone visiting in this future:
Just use emojis, they align perfectly and built-in on most platforms
On windows, you can press Win+Ю (period button) and select them there
—
Reply to this email directly, view it on GitHub<#206 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAB2ZPBVUSASBT32XRPJXSLUWGJZZANCNFSM4BO3YEVA>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Hi,
Material icons doesn't seems to vertical align themselves when placed alongside any text.
Issue:
I am using this code:
Let me know if I am doing anything wrong.
I am using Bootstrap v 3.3.5.
The text was updated successfully, but these errors were encountered: