可通过以下方式解决:
在CSS文件中,设置body和html的高度为100%,并将页面包裹在一个容器div中。对于页脚样式,可以设置其样式为position: absolute; bottom: 0;。这样,页脚样式就会始终保持在页面底部。
示例代码:
// CSS样式 html, body { height: 100%; margin: 0; padding: 0; }
.container { min-height: 100%; position: relative; }
.footer { position: absolute; bottom: 0; width: 100%; height: 50px; /* 根据实际需求调整 */ }
// 页面结构
Antd提供了Layout组件,其中包括Header、Content、Footer等子组件。通过使用Layout.Footer组件,可以轻松实现页脚固定在页面底部的效果。
示例代码:
import { Layout } from 'antd'; const { Footer } = Layout;