css布局问题

clipboard.png

有以上html结构,header占满整个屏幕的宽度,left宽度固定200px,right内容是由iframe宽度占满剩余的宽度,并且content的高度占满整个屏幕,怎么使用css布局实现上面的结构?

阅读 2.4k
2 个回答
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            header{
                background: lightcoral;
                height: 100px;
            }
            .content{
                position: absolute;
                left: 0px;
                right: 0px;
                top: 100px;
                bottom: 0px;
            }
            .left{
                width: 200px;
                background: lightskyblue;
                position: absolute;
                top: 0;
                bottom: 0;
            }
            .right{
                left: 200px;
                right: 0px;
                background: orange;
                position: absolute;
                top: 0;
                bottom: 0;
            }
        </style>
    </head>
    <body>
        <header></header>
        <div class="content">
            <div class="left"></div>
            <div class="right"></div>
        </div>
    </body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>
    body {
      height: 100vh;
      margin: 0;
      padding: 0;
    }
    .header {
      height: 60px;
      background: #ffbf00;
    }
    .content {
      display: flex;
      height: calc(100% - 60px);
      background: #0c86ff;
    }
    .left {
      width: 300px;
      background: #00a854;
    }
    .right {
      width: calc(100% - 300px);
      background: red;
    }
  </style>
</head>
<body>
  <div class="header"></div>
  <div class="content">
    <div class="left"></div>
    <div class="right"></div>
  </div>
</body>
</html>

图片描述

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题