【问题标题】:Material select remove empty space材料选择删除空白空间
【发布时间】:2022-08-13 20:45:49
【问题描述】:

删除空白空间材料选择/输入的最佳方法是什么? 我的意思是让字段的宽度与内容的大小相同。

https://material.angular.io/components/select/overview

    标签: angular material-ui angular-material


    【解决方案1】:

    你可以试试这个:

    
    .auto-width{
        .mat-form-field {
            width: auto !important;
        }
        .mat-select-value {
            max-width: 100%;
            min-width: 100%;
        }  
    }
    

    并在您的 html 内容上:

    <div class="auto-width">
        <mat-form-field>
          <mat-select>
            <mat-option value="long">Long description</mat-option>
            <mat-option value="foo">Foo</mat-option>      
          </mat-select>
        </mat-form-field>
    </div>
    

    从这个old answer

    【讨论】: