简体   繁体   English

Angular2材质md-icon尺寸

[英]Angular2 Material md-icon size

How do I get the icon size to work with the relative size of the font in angular2? 如何使图标大小与angular2中字体的相对大小一起使用?

<div style="font-size: 3em;">
<md-icon>highlight</md-icon>
Title
</div>

In your CSS file you can modify the md-icon size by modifying font-size, height and width. 在CSS文件中,您可以通过修改字体大小,高度和宽度来修改md-icon大小。 For example: 例如:

md-icon.size-45 {
    font-size: 45px;
    height: 45px;
    width: 45px;
}

There are two ways to approach this. 有两种方法可以解决这个问题。

You can influence the ligature itself: 你可以影响结扎本身:

<md-icon><h1>highlight</h1></md-icon>

This will resize the icon, but it will be influenced by styles set on the header elements (like font-weight ). 这将调整图标的大小,但它会受标题元素上设置的样式(如font-weight )的影响。 So, I would recommend resizing using CSS: 所以, 我建议使用CSS调整大小:

<md-icon style="font-size:24px">highlight<md-icon>

This will resize the icon crisply. 这将清晰地调整图标的大小。 You can of course also add classes to do that (which is even better!): 你当然也可以添加类来做到这一点(这更好!):

<md-icon class="large">highlight<md-icon>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM