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条回答
孤傲高冷的网名
2楼-- · 2020-02-23 05:38

if you are using scss

@mixin md-icon-size($size: 24px) {
  font-size: $size;
  height: $size;
  width: $size;
}

.md-icon-16 {
  @include md-icon-size(16px);
}

.md-icon-18 {
  @include md-icon-size(18px);
}

.md-icon-24 {
  @include md-icon-size(24px);
}

.md-icon-36 {
  @include md-icon-size(36px);
}
查看更多
萌系小妹纸
3楼-- · 2020-02-23 05:39

I followed the answer delivered by Claudios and had to do an additional change. I am using MDL and for the icon to be centered in a button it was necessary to change position left property (default is left:50%).

CSS:

.material-icons.md-36 { 
font-size: 36px; 
position: absolute;
left: 40%;
}

And in HTML:

<i class="material-icons md-36">face</i>
查看更多
We Are One
4楼-- · 2020-02-23 05:42

Sometimes setting font size will not reduce the icon size. Coz, the recommended font-size is either 18, 24, 36 or 48px.

Try setting "height" , "width", "line-height" attributes for that particular icon. This might help.

查看更多
登录 后发表回答