【问题标题】:Styling angular material input造型角材质输入
【发布时间】:2020-01-02 09:04:00
【问题描述】:

我创建了一个大纲文本框:

<mat-form-field appearance="outline">
    <input matInput placeholder="Username">
  </mat-form-field>

我正在尝试使用以下方法控制高度、边框颜色:

.mat-form-field {
  height:20px;
  border:1px solid #f0f;
}

但结果远非预期。有没有办法可以做到? 我在stackblitz上创建的示例代码https://stackblitz.com/edit/angular-material-custom-input-j3k2h

【问题讨论】:

    标签: angular angular-material


    【解决方案1】:

    您可以添加此样式来编辑高度:

    .mat-form-field-infix {padding:0 !important; border:0 !important;}
    .mat-form-field-flex{ margin:0 !important; padding:5px !important; padding-bottom: 17px !important; height: 20px !important;}
    .mat-form-field-wrapper { padding: 0 !important; }
    

    还有这个来编辑边框颜色:

    .mat-form-field-appearance-outline .mat-form-field-outline {
      color: #f0f;
    }
    

    【讨论】:

    • 谢谢,边框颜色有效,但高度保持不变
    • 那行得通。将输入放置到顶部边框,但这是可以管理的。谢谢
    猜你喜欢
    • 1970-01-01
    • 2018-12-10
    • 2015-12-11
    • 1970-01-01
    • 2020-04-22
    • 2017-11-22
    • 1970-01-01
    • 2021-09-13
    • 1970-01-01
    相关资源
    最近更新 更多