实现的效果

模仿小米:https://www.mi.com/
image.png

1

先布局好模块就可以了,内容前面写过。

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. }
  13. .father {
  14. width: 1225px;
  15. height: 460px;
  16. margin: 10px auto;
  17. }
  18. .left {
  19. float: left;
  20. width: 235px;
  21. height: 460px;
  22. background-color: #6b7f8c;
  23. }
  24. .right {
  25. float: left;
  26. height: 460px;
  27. width: 990px;
  28. background-color: #90b9d2;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div class="father">
  34. <div class="left"></div>
  35. <div class="right"></div>
  36. </div>
  37. </body>
  38. </html>

image.png

2

image.png
这种有空隙的布局可以用margin-right,最后一个不用。

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

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

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

    div {
      width: 1728px;
      height: 405px;
      background-color: pink;
      margin: 0 auto;
    }

    li {
      list-style: none;
    }

    ul li {
      float: left;
      width: 418px;
      height: 405px;
      background-color: blue;
      margin-right: 18px;
    }

    ul .last {
      margin-right: 0;
    }
  </style>
</head>

<body>
  <div>
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li class="last">4</li>
    </ul>
  </div>
</body>

</html>

image.png

手机模块(上)

image.png
做这个模块布局。

image.png

image.png
所以:一个大的div包两个子div
右div包8个子盒子。用div也行,用ul li也行。

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

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

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

    .box {
      width: 1240px;
      height: 628px;
      background-color: pink;
      margin: 0 auto;
    }

    .left {
      float: left;
      margin-left: 14px;
      width: 234px;
      height: 628px;
      background-color: blue;
    }

    .right {
      float: left;
      margin-left: 14px;
      width: 992px;
      height: 628px;
      background-color: red;
    }
  </style>
</head>

<body>

  <div class="box">
    <div class="left"></div>
    <div class="right"></div>
  </div>
</body>

</html>

image.png

image.png

手机模块(下)

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

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

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

    .box {
      width: 1240px;
      height: 628px;
      background-color: pink;
      margin: 0 auto;
    }

    .left {
      float: left;
      margin-left: 14px;
      width: 234px;
      height: 628px;
      background-color: blue;
    }

    .right {
      float: left;
      width: 992px;
      height: 628px;
      background-color: red;
    }

    .right div {
      float: left;
      width: 234px;
      height: 300px;
      background-color: skyblue;
      margin-left: 14px;
      margin-bottom: 14px;
    }
  </style>
</head>

<body>

  <div class="box">
    <div class="left"></div>
    <div class="right">
      <div>1</div>
      <div>2</div>
      <div>3</div>
      <div>4</div>
      <div>5</div>
      <div>6</div>
      <div>7</div>
      <div>8</div>
    </div>
  </div>
</body>

</html>
    .right div {
      float: left;
      width: 234px;
      height: 300px;
      background-color: skyblue;
      margin-left: 14px;
      margin-bottom: 14px;
    }

image.png