如何在使用文本区域标签时更改文本区域的宽度



antd库中,在一个名为 ant-input 的类中,一个名为 350px !important 的字段将textareawidth固定为 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 }} />

然而,事实证明它并不真正可靠。

最新更新