【发布时间】:2016-09-16 16:13:25
【问题描述】:
我正在尝试通过此处的文档为其分配类来设置 React Bootstrap 模式的样式
prop: dialogClassName
type: string
description: A css class to apply to the Modal dialog DOM node.
但是,它没有显示为有效的类。
Flexbox、背景色等似乎不适用于 Modal 父级的任何子级,这让我认为要么 Modal 禁用任何样式,要么我做错了事
谢谢!
<ExampleModal
dialogClassName="planModal" <--Tried here
modalState={this.props.modalState}
openModal={this.props.actions.openModal}
mealPlanArray={this.props.mealPlanArray}/>
ExampleModal 的渲染看起来像这样
render() {
if (!this.props.modalState.openDisplay) { return ( <span/>) }
return (
<Modal className="TriedHere" show={this.props.modalState.openDisplay} onHide={this.props.openModal}>
<Modal.Header>
<h2>Bot Activated</h2>
</Modal.Header>
<Modal.Body>
{this.renderResults()}
</Modal.Body>
</Modal>
);
}
}
谁能想出一种方法来设置 React Modal 内容的样式?
【问题讨论】:
-
把
dialogClassName属性放在<Modal ..? -
正如 azium 所说,它是
<Modal />组件的道具,如果您希望从父组件传入它,那么在这种情况下您将拥有:<Modal dialogClassName={this.props.dialogClassName} ... />
标签: css reactjs bootstrap-modal react-bootstrap