使用TextArea标签时如何更改textarea的宽度

时间:2019-06-17 18:34:31

标签: css reactjs antd

antd库中,在名为ant-input的类中,名为350px !important的字段将width的{​​{1}}固定为textarea,并且我无法覆盖此字段。

我搜索了350px https://ant.design/components/input-cn/提供的文档,但是他们没有提供允许我更改宽度的api。

antd

我希望覆盖默认值的.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不允许这样做。

2 个答案:

答案 0 :(得分:0)

请尝试仅传递样式参数,例如:

<Input.TextArea style={{ width: 500 }} />

在此处查看:https://codesandbox.io/embed/cocky-hugle-e9eu1

答案 1 :(得分:0)

对我来说,它不起作用,但这行得通:

<Input.TextArea style={{ width: 500, max-width: 500 }} />

但是,事实证明它并不可靠。