首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >antd css - antd Modal css不加载

antd css - antd Modal css不加载
EN

Stack Overflow用户
提问于 2022-11-22 05:11:42
回答 2查看 45关注 0票数 0

我已经创建了一个and模式,我想将模态体颜色更改为红色,这是我的代码,已经应用了背景颜色,但它没有显示,我也想用flex对齐图像和modalName,我已经插入了and版本4.2,我使用的是样式的组件。不知道什么是wrong.please的帮助,并感谢提前。

代码语言:javascript
复制

modal.js

代码语言:javascript
复制
import React , {useState}  from "react";
import { Modal ,Button} from "antd";
import styled from "styled-components";
import "antd/dist/antd.css";

const Modall = () => {
    const [isModalVisible, setIsModalVisible] = useState(false);

    const showModal = () => {
      setIsModalVisible(true);
    }
  
    const handleOk = () => {
      setIsModalVisible(false);
    }
  
    const handleCancel = () => {
      setIsModalVisible(false);
    }
    return (
        
            <Wrapper>
                <div className="head">hello</div>
                <Button type="primary" onClick={showModal}>
                    Open Modal
                </Button>
                <Modal
                    title="Basic Modal"
                    open={isModalVisible}
                    onOk={handleOk}
                    onCancel={handleCancel}
                    
                >
                   <div className="modalName">hello</div>
                  <div className="modalHead">
                     <img src='simple.svg' className="newStyle"></img>
                      <div className="modalName" >beautiful</div>
                  /div>
                </Modal>            
            </Wrapper>
       
    );
}
export default Modall;



const Wrapper = styled.div`
.ant-modal, .ant-modal-content .ant-modal-body .modalHead{
display:flex;
}
.ant-modal, .ant-modal-content .ant-modal-body{
 background:red;
 }

`
EN

回答 2

Stack Overflow用户

发布于 2022-11-22 05:26:25

不确定,但我认为您需要在您的模式中添加“bodyStyle”,以便在您的模式中添加一个背景,有点像这样

代码语言:javascript
复制
         <Modal
          title="Basic Modal"
          open={isModalVisible}
          onOk={handleOk}
          onCancel={handleCancel}
          bodyStyle={{
            backgroundColor: "red"
          }}
          
        >
票数 1
EN

Stack Overflow用户

发布于 2022-11-22 05:22:25

您应该将Wrapper放在模态体中,尝试如下:

代码语言:javascript
复制
    return (
            <>
                <div className="head">hello</div>
                <Button type="primary" onClick={showModal}>
                    Open Modal
                </Button>
                <Modal
                    title="Basic Modal"
                    open={isModalVisible}
                    onOk={handleOk}
                    onCancel={handleCancel}
                    className="modalStyle"
                >
                  <Wrapper><div className="modalName">hello</div></Wrapper>
                </Modal>            
            </>
       
    );
    
const Wrapper = styled.div`
 background:red;
`

https://codesandbox.io/s/determined-chatelet-es5big?file=/src/App.js

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74527764

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档