使用ant design 创建简单的页面布局

import { Layout, Menu, Popconfirm, Button } from 'antd'
import { PieChartOutlined, SolutionOutlined, FileWordOutlined, LogoutOutlined } from '@ant-design/icons'
import './index.scss'
const { Header, Sider, Content } = Layout

const GeekLayout = () => {
  return (
    <Layout className="papap-layout">
      <Sider width={148} className="site-layout-background">
        <div className="logo">PAPAP</div>
        <Menu defaultSelectedKeys={['1']} mode="inline" theme="dark">
          <Menu.Item icon={<PieChartOutlined />} key="1">
            数据面板
          </Menu.Item>
          <Menu.Item icon={<SolutionOutlined />} key="2">
            内容管理
          </Menu.Item>
          <Menu.Item icon={<FileWordOutlined />} key="3">
            发布文章
          </Menu.Item>
        </Menu>
      </Sider>
      <Layout>
        <Header>
          <span style={{ fontSize: 16 }}>简单的布局</span>
          <div>
            <span>{}</span>
            <Popconfirm placement="bottomRight" title="您确认退出吗?" okText="确认" cancelText="取消">
              <Button type="link" icon={<LogoutOutlined />}>
                退出
              </Button>
            </Popconfirm>
          </div>
        </Header>
        <Content>内容</Content>
      </Layout>
    </Layout>
  )
}

export default GeekLayout
.papap-layout {
  height: 100%;
  overflow: hidden;
  .ant-layout-header {
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
  }
  .ant-menu.ant-menu-dark {
    .ant-menu-item {
      padding-left: 50px;
    }
    .ant-menu-item-selected {
      background: #048;
    }
  }
  .ant-layout-content {
    height: 100%;
    overflow-y: auto;
  }
  .logo {
    width: 100%;
    height: 64px;
    color: #f8f8f8;
    font-size: 30px;
    text-align: center;
    text-shadow: 3px 3px 5px #f8f8f8;
    line-height: 64px;
    letter-spacing: 0.1em;
    transform: skew(-10deg);
    margin-bottom: 20px;
    user-select: none;
  }
}

实现效果

 

ps:  ant提供的theme有两种light | dark模式可选择

 高度撑开要在父级盒子有高度(100vh或者height:100%)情况下 height:100% 才会生效

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值