zl程序教程

您现在的位置是:首页 >  Javascript

当前栏目

前端面试 【CSS】— CSS如何实现双飞翼布局?

2023-03-14 22:52:31 时间

双飞翼布局如下所示:

以下是代码实现:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .container {
      min-width: 600px;
    }

    .left {
      float: left;
      width: 200px;
      height: 400px;
      background: red;
      margin-left: -100%;
    }

    .center {
      float: left;
      width: 100%;
      height: 500px;
      background: yellow;
    }

    .center .inner {
      margin: 0 200px;
      height: 400px;
    }

    .right {
      float: left;
      width: 200px;
      height: 400px;
      background: blue;
      margin-left: -200px;
    }
  </style>
</head>

<body>
  <article class="container">
    <div class="center">
      <div class="inner">双飞翼布局</div>
    </div>
    <div class="left">左边</div>
    <div class="right">右边</div>
  </article>
</body>

</html>