首页 > 解决方案 > 如何减小 MatSelect DropDown Panel 的大小

问题描述

我正在尝试减小 mat-select 下拉面板的默认大小,但不知道该怎么做

我试过给出宽度,试过在角垫选择中覆盖面板类,但尺寸似乎没有下降

我的模板文件

    <div class="col-md-8">
       <mat-form-field style="float: right">
          <mat-select panelclass="my-panel" placeholder="Select Course"(selectionChange)="selectCourse($event,courses)" disableOptionCentering>
         <mat-option *ngFor="let course of courses" [value]="course.courseId">
          {{course.courseCode}}
        </mat-option>
      </mat-select>
    </mat-form-field>
  </div>

我的 CSS 文件

 .my-panel {
   background: orange;
   height: 300px;
   display: flex;
   flex-direction: column;
   justify-content: space-between;
   min-width: 350px !important;
   }

预期结果 :
预期结果

实际结果 : 实际结果

新问题

标签: angularangular-materialangular-material-6

解决方案


您可以通过将以下 css 添加到主styles.css文件来设置 mat-select 的宽度。

.mat-form-field-infix{
    width: 80px !important;
}

根据您的要求更改 80px。


推荐阅读