html - Angular Material 文本区域占位符和文本对齐问题

标签 html css angular sass angular-material

我有一个 `textarea 的 Angular ,看起来如下:

enter image description here

在 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;
}

这里有两个问题。

  1. 本应 float 在 textarea 上方的 placeholder 没有看到。
  2. 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/

相关文章:

php - MySQL 插入查询返回 false

html - 如何仅在一个边缘上禁用阴影?

angular - 如何在 Angular 错误上获得更好的堆栈跟踪

Angular 4剑道对话框如何从对话框中读取更新的值

java - org.springframework.web.HttpMediaTypeNotAcceptableException : Could not find acceptable representation in java spring boot

html - CSS 背景不可点击 - href =""不工作

javascript - jquery 用户界面错误 "undefined is not a function"

css - 如何使 JPG 仅在悬停时加载?

html - 任何 div 内文本的 css 位置和中心不起作用

html - li 元素的导航和文本