gpt4 book ai didi

reactjs - 在 React Bootstrap 中居中模式标题和按钮

转载 作者:行者123 更新时间:2023-12-04 08:40:00 25 4
gpt4 key购买 nike

我正在尝试为我的项目实现 React Modal。我想将模态标题和模态按钮居中。我尝试使用 flex 和 just-content-center 但它没有用。任何建议都是有值(value)的。

<Modal show={modalShow} onHide={this.handleClose} aria-labelledby="contained-modal-title-vcenter" centered>
<Modal.Header closeButton>
<div className="d-flex justify-content-center">
<Modal.Title>{isVerified?"Submitted succesfully":"Failed to submit"}</Modal.Title>
</div>
</Modal.Header>
<Modal.Footer>
<Button variant={`${isVerified == false?"danger ":"success"}`} onClick={this.handleClose} centered>
{isVerified?"Ok":"Try again"}
</Button>
</Modal.Footer>
</Modal>

最佳答案

我尝试了不同的类(class),但有效的是:

import React from "react";
import { Modal, Button } from "react-bootstrap";

const ModalPage = ({ modalShow, handleClose, isVerified }) => {
return (
<Modal
show={modalShow}
onHide={handleClose}
aria-labelledby="contained-modal-title-vcenter"
centered
>
<Modal.Header
closeButton
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
<Modal.Title>
{isVerified ? "Submitted succesfully" : "Failed to submit"}
</Modal.Title>
</Modal.Header>
<Modal.Footer
style={{
display: "flex",
justifyContent: "center",
}}
>
<Button
variant={`${isVerified == false ? "danger " : "success"}`}
onClick={handleClose}
centered
>
{isVerified ? "Ok" : "Try again"}
</Button>
</Modal.Footer>
</Modal>
);
};

export default ModalPage;

关于reactjs - 在 React Bootstrap 中居中模式标题和按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64624014/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com