html 各种布局整理 -- 1

废话不多说直接上代码

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>css真正的精髓</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      color:#fff;
    }

    #container {
      min-width: 1260px;
      width:1260px;
      height:100vh;
      margin: 0 auto;
    }
    #header {
      background: rgb(128, 226, 149);
      height:70px;
    }
    #content {
      /* 内容区 利用calc计算属性*/
      min-height: calc(100vh - 70px - 100px); 
      /* min-height: 1000px; */
      background: rgb(209, 149, 149);
    }
    #footer {
      height: 100px;
      background: #333;
    }
    .white{
      color: #fff;
    }
  </style>
</head>

<body>
  <div id="container">
    <!-- <div id="header">网页头部</div>
    <div id="content" class="white">网页内容</div>
    <div id="footer" class="white">网页底部</div> -->
    <!-- h5 语义化 -->
    <header id="header">网页头部</header>
    <main id="content">网页内容</main>
    <footer id="footer">网页底部</footer>
  </div>
</body>
</html>

效果

在这里插入图片描述
一个最小宽度 配合居中显示的这么一个布局方式

然后可以弃用浏览器的滚动条 给网页主题内容 content 加个滚动条就可以了 这种布局方式几乎适配主流显示器

用到了计算属性 calc()

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值