7 html javascript css reactjs antd
我是编程新手。这里我有一个 antd 模态,我一直在尝试找到一种使其全屏显示的方法。我希望模式在打开时是全屏的,并且不应该有任何边距或填充。例如,在我添加的代码中,width={1000}
但模态框的左侧和右侧仍然有一些边距。
那么如何使模态占据整个屏幕而没有任何边距和填充呢?
width
和属性的固定值:centered
索引.js
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import 'antd/dist/antd.css';
import './index.css';
import { Modal, Button } from 'antd';
const App = () => {
const [visible, setVisible] = useState(false);
return (
<>
<Button type="primary" onClick={() => setVisible(true)}>
Open Modal of 1000px width
</Button>
<Modal
title="Modal 1000px width"
// This was removed
// centered
visible={visible}
onOk={() => setVisible(false)}
onCancel={() => setVisible(false)}
// This was removed
// width={'1000'}
>
<p>some contents...</p>
<p>some contents...</p>
<p>some contents...</p>
</Modal>
</>
);
};
ReactDOM.render(<App />, document.getElementById('container'));
Run Code Online (Sandbox Code Playgroud)
索引.css
.ant-modal, .ant-modal-content {
height: 100vh;
width: 100vw;
margin: 0;
top: 0;
}
.ant-modal-body {
height: calc(100vh - 110px);
}
Run Code Online (Sandbox Code Playgroud)