页面布局文档

本文探讨了五种不同的页面布局方法:不建议的全局样式重置、上中下结构、topmain结构、mainbottom结构以及全屏结构。每种方法都有其特点,例如固定顶部的导航栏、自适应内容区域以及底部固定元素。通过实例代码展示了如何实现这些布局,为前端开发者提供了布局选择的参考。
摘要由CSDN通过智能技术生成

页面布局

1.不建议方法

  <style>
    * {
      padding: 0;
      margin: 0;
    }

    .top {
      position: fixed;
      height: 80px;
      right: 0;
      left: 0;
      top: 0;
      background-color: pink;
    }

    .main {
      margin-top: 80px;
    }
  </style>
</head>

<body>
  <div class="top"></div>
  <div class="main">
    
  </div>
</body>

</html>

2.上中下结构

<style>
    .top {
      position: absolute;
      height: 70px;
      top: 0;
      left: 0;
      right: 0;
      background-color: pink;
    }

    .main {
      position: absolute;
      top: 70px;
      bottom: 80px;
      right: 0;
      left: 0;
      overflow: auto;
    }

    .bottom {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 80px;
      background-color: skyblue;
    }
  </style>

3. top main结构

<style>
    .top {
      position: absolute;
      height: 80px;
      top: 0;
      left: 0;
      right: 0;
      background-color: pink;

    }

    .main {
      position: absolute;
      top: 80px;
      left: 0;
      right: 0;
      overflow: auto;
    }
  </style>

4.main bottom

 <style>
    .main {
      overflow: auto;
      position: absolute;
      bottom: 80px;
      top: 0;
      left: 0;
      right: 0;
    }

    .bottom {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 80px;
      background-color: skyblue;
    }
  </style>

5.全屏结构

 <style>
    .main {
      position: absolute;
      overflow: auto;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
    }
  </style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值