angular 5 material - form fields stuck at 180px

后端 未结 6 1234
感动是毒
感动是毒 2020-12-29 01:26

Ive create a form in a dialog using material forms but I cant seem to get the inputs to be wider than 180px despite following numerous examples including https://material.an

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 01:29

    Just like Jonesie said, this behavior is related to View Encapsulation. In this context .mat-form-field-infix takes 180px as default value probably beacause of this. The auto value lets the browser calculates the width instead of puting hardcoded value. The !important declarations forces the style override for this.
    I am using !important since it complies with the rules for the use of this property. See docs

    ::ng-deep .mat-form-field-infix {
        width: auto !important;
    }
    

提交回复
热议问题