Change the icon size of AngularJS Material icons

前端 未结 9 1544
不思量自难忘°
不思量自难忘° 2020-12-25 10:11

I have referenced then declared an icon

face

But how can I change the icon size?

On of

相关标签:
9条回答
  • 2020-12-25 10:12

    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

    0 讨论(0)
  • 2020-12-25 10:15

    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);
    }
    
    0 讨论(0)
  • 2020-12-25 10:16

    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.

    0 讨论(0)
  • 2020-12-25 10:17

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

    0 讨论(0)
  • 2020-12-25 10:20

    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.

    0 讨论(0)
  • 2020-12-25 10:26

    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>
    
    0 讨论(0)
提交回复
热议问题