在一个 React 项目中,我使用 Ant Design (Antd) 作为 CSS 框架。因此,我们需要更改作为 Antd 组件的 Modal 的样式。改变它的 Modal 组件的边界半径是预料之中的,但是,经过多次尝试,一切都是徒劳的。有没有合适的解决方案?
- 模态组件
<Modal
title="Basic Modal"
visible={isModalVisible}
onOk={handleOk}
onCancel={handleCancel}
className="modalStyle"
//bodyStyle={{ borderRadius: "20px" }} {/* Also tried with bodyStyle property */}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
索引.css
.modalStyle {
border-radius: 20px;
}
.newStyle {
border-radius: 20px;
}
/* applied style to its root properties, but no change */
.ant-modal-content {
border-radius: 20px;
}
以下是代码框链接:https ://codesandbox.io/s/basic-antd4168-forked-rz764