【发布时间】:2020-03-27 14:47:48
【问题描述】:
目标:减小特定 mat-form-field 的高度(但仍将其保持在原位,在“请登录”的右侧)。 它应该在文本值和下拉箭头周围占用最少的空间。
目前看起来是这样的:
我希望它周围框上的线条更接近单词 English 和向下箭头。 该框是通过添加以下内容创建的:appearance="outline"
问题:我能够成功更改宽度,但不能更改高度。
我的尝试:
我浏览过 SO 文章,例如 How to change height in mat-form-field 和 Adjusting height of mat-form-field Angular Material
我已尝试自行调整高度(高度:40 像素)
我已尝试最小化填充以使其看起来更小 (padding-top: -1.84375em;)
我尝试在 Chrome Devtools 中更改它,但文本随后对齐 盒子底部
HTML:
<div class="title-container">
<mat-card-title class="text-center" i18n="@@MoVeSeLo_H1_1">
Please Sign In
</mat-card-title>
<form [formGroup]="_siteForm">
<mat-form-field class="language-field" appearance="outline">
<mat-select (selectionChange)="doSomething($event)" [value]="languages[i]">
<mat-option *ngFor="let language of languages" [value]="language">
{{language.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
</form>
</div>
CSS:
.title-container {
position: relative;
margin-top: 8px;
}
.language-field {
position: absolute;
right: 0;
top: 0;
margin-top: -16px;
width: 115px;
height:40px;
padding-top: -1.84375em;
}
【问题讨论】: