antd
库中,在一个名为 ant-input
的类中,一个名为 350px !important
的字段将textarea
的width
固定为 350px
,我无法覆盖此字段。
我搜索了antd
https://ant.design/components/input-cn/提供的文档,他们没有提供允许我更改宽度的 api。
.ant-input {
color: var(--text-primary-color) !important;
font-family: var(--text-primary-font-family);
box-shadow: none;
width: 350px !important;
height: 50px;
box-shadow: none;
border: 1px solid var(--input-box-border-color) !important;
border-radius: 0px;
}
我希望覆盖默认值的width
,但!important
不允许我这样做。
请尝试只传递样式参数,例如:
<Input.TextArea style={{ width: 500 }} />
在这里看到它: https://codesandbox.io/embed/cocky-hugle-e9eu1
,它不起作用,但这奏效了:
<Input.TextArea style={{ width: 500, max-width: 500 }} />
然而,事实证明它并不真正可靠。