CSS双飞翼布局

双飞翼布局是一种经典的CSS布局模式,主要用于实现左右两列固定宽度,中间列自适应的布局。

比如:写一个左中右布局占满全屏,其中左、右两块固定宽 200px,中间自适应,要求先加载中间块。

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>双飞翼布局</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        width: 100vw;
        height: 100vh;
        color: #fff;
      }
        /* 内容区域 */
        .container > div {
          float: left;
        }

        /* 左侧栏 */
        .left {
          width: 200px;
          height: 100vh;
          margin-left: -100%;
          background-color: red;
        }

        /* 右侧栏 */
        .right {
          width: 200px;
          height: 100vh;
          margin-left: -200px;
          background-color: blue;
        }

        /* 中间栏 */
        .middle {
          width: 100%;
          height: 100vh;
          background-color: pink;
        }
        .main {
          padding: 0 200px;
        }
    </style>
</head>
<body>
  <!-- 双飞翼布局 -->
    <div class="container">
        <div class="middle">
          <div class="main">中间自适应内容</div>
        </div>
        <div class="left">左侧固定宽度</div>
        <div class="right">右侧固定宽度</div>
    </div>
</body>
</html>

左右 200px 中间自适应

相关推荐
用户0595401744620 分钟前
AI Agent记忆测试踩坑实录:Mock骗了我一周,Mem0+pytest一招破局
前端·css
Darling噜啦啦1 天前
CSS 3D 变换与 Flex 布局实战:从零打造旋转立方体
前端·css
用户059540174461 天前
把待办应用从Electron换成Tauri,内存占用狂降90%,打包体积仅5MB
前端·css
小月土星2 天前
CSS 3D 从入门到炫技:手把手教你写一个旋转立方体
前端·css
xingpanvip2 天前
星盘接口开发文档:本命盘接口指南
android·开发语言·css·php·lua
HjhIron2 天前
CSS 3D 世界:从盒子模型到三维空间动画
javascript·css
参宿72 天前
CSS 悬挂空白与选区溢出
前端·css
黄敬峰2 天前
纯 CSS3 打造 3D 旋转魔方:从文档流、Flex 布局到空间变换的硬核复盘
css
JieE2122 天前
手把手带你用纯 CSS 实现一个 3D 旋转魔方,这些前端基础你能打几分?
前端·css·html
JYeontu2 天前
开箱流水加载动画
前端·javascript·css