我有一个 `textarea 的 Angular ,看起来如下:
在 Angular 上,我有:
<div *ngIf="whetherDisplay()" class="textarea-text">
<mat-form-field appearance="outline" >
<textarea matInput name="myTextarea" disabled class="myTextarea" rows="3"
placeholder="This is a placeholder">
{{ ttsText }}
</textarea>
</mat-form-field>
</div>
CSS:
.greeting-tts-text {
width: 65%;
margin: 5px auto 0 auto;
}
这里有两个问题。
- 本应 float 在
textarea
上方的placeholder
没有看到。 textarea
中文本的开头(“This is dummy text”)移动到右侧。为什么会这样?
我做错了什么?
最佳答案
这是因为你在 textarea
中没有标签,你需要这样的 floatLabel="never"
<mat-form-field appearance="outline" floatLabel="never" class="display-block">
<textarea rows="3" matInput placeholder="Type here..." disabled></textarea>
</mat-form-field>
来自 Angular Material 文档 Float label never
关于html - Angular Material 文本区域占位符和文本对齐问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59105506/