Change the icon size of AngularJS Material icons

2020-02-23 05:09发布

I have referenced then declared an icon

<i class="material-icons">face</i>

But how can I change the icon size?

On oficial site https://design.google.com/icons/ I can see they using classes like class="md-icon dp48" but it is not working in my case.

9条回答
Lonely孤独者°
2楼-- · 2020-02-23 05:21

you can change the font-size property, it will reflect on the icon because it's a "FONT ICON"

查看更多
小情绪 Triste *
3楼-- · 2020-02-23 05:24

By reading the material design in github I found these useful stuff that might help you.

 /* Rules for sizing the icon. */
.material-icons.md-18 { font-size: 18px; }
.material-icons.md-24 { font-size: 24px; }
.material-icons.md-36 { font-size: 36px; }
.material-icons.md-48 { font-size: 48px; }

/* Rules for using icons as black on a light background. */
.material-icons.md-dark { color: rgba(0, 0, 0, 0.54); }
.material-icons.md-dark.md-inactive { color: rgba(0, 0, 0, 0.26); }

/* Rules for using icons as white on a dark background. */
.material-icons.md-light { color: rgba(255, 255, 255, 1); }
.material-icons.md-light.md-inactive { color: rgba(255, 255, 255, 0.3); }

From the code above, there you can simply change or override the material css icons.

Sample code:

<i class="material-icons md-18">face</i>

More details here

查看更多
地球回转人心会变
4楼-- · 2020-02-23 05:24

There is a size attribute associated with icon tag like check_circle

so using size attribute, we can change the size of the icons.

查看更多
劫难
5楼-- · 2020-02-23 05:30

You can use normal css, but must override inline styling with:

font-size: 50px !important;

查看更多
6楼-- · 2020-02-23 05:33

If I'm doing a one-off I usually just add a style= modification to the font-size in the tag. But yes long story short there's no real trick to it other than defining your own size styles to attach in css as a more permanent solution.

<i class="material-icons" style="font-size: 50px">insert_invitation</i>
查看更多
不美不萌又怎样
7楼-- · 2020-02-23 05:33

The best way to change the size of a Materialize Icon is by adding a modifier to the i class:

<i class="material-icons small">menu</i>
<i class="material-icons medium">menu</i>
<i class="material-icons large">menu</i>

You can find more on changing the icon size on the Materialize site under icons.

查看更多
登录 后发表回答