本文介绍了如何在浮动占位符的角度材料形式字段中更改字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是角材料的表单域.如何在正常和浮动时为占位符添加 2 种不同的自定义字体大小.字体大小:20px;(正常时)字体大小:13px;(当它浮起来变小时)
Below is the form field of angular material.How can I add 2 different customize font-size for placeholder when it's normal and when it floats.font-size : 20px; (When it is normal)font-size : 13px; (When it floats up and get smaller)
<mat-form-field class="form-group example-full-width">
<input matInput id="Fname" placeholder="First" class=" " formControlName="FirstName">
<mat-error *ngIf="firstName.invalid" class="">First name is required</mat-error>
</mat-form-field>
推荐答案
浮动文本是一个可以用 css 定位的标签.像这样的事情可能会奏效.
The floating text is a label that can be targeted with css. Something like this may work.
mat-form-field label {
font-size: 20px;
}
当标签浮动时
mat-form-field.mat-form-field-should-float label {
font-size: 13px;
}
这篇关于如何在浮动占位符的角度材料形式字段中更改字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!