![](/img/trans.png)
[英]How to customize the CSS in Angular material 7 drag and drop while dragging, drag preview and drag placeholder?
[英]How to customize the placeholder in angular 7
如前所述这里 ,
如果要创建不带占位符但不带标签的旧式表单字段,则需要指定一个空标签以防止占位符被提升。
因此,您可以尝试以下操作:
<mat-form-field class="example-full-width">
<mat-label></mat-label>
<input matInput placeholder="Just a placeholder">
</mat-form-field>
我创建了一个stackblitz ,请检查最底部的输入字段。
UPDATE
为了使占位符既处于聚焦状态又处于模糊状态,可以尝试在*ngIf
<mat-label>
上添加*ngIf
语句,该值将因focus
和blur
事件而改变:
<mat-form-field class="example-full-width">
<mat-label *ngIf="focused"></mat-label>
<input matInput
placeholder="Just a placeholder"
(blur)="focused=false"
(focus)="focused=true">
</mat-form-field>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.