First, product word layout

1.1

* {
  margin: 0;
  padding: 0;
}
body {
  overflow: hidden;
}
div {
  margin: auto 0;
  width: 100px;
  height: 100px;
  background: red;
  font-size: 40px;
  line-height: 100px;
  color: #fff;
  text-align: center;
}

.div1 {
  margin: 100px auto 0;
}

.div2 {
  margin-left: 50%;
  background: green;
  float: left;
  transform: translateX(-100%);
}

.div3 {
  background: blue;
  float: left;
  transform: translateX(-100%);
}
Copy the code
<div class="div1">1</div>
<div class="div2">2</div>
<div class="div3">3</div>
Copy the code

Full screen version 1.2

* {
  margin: 0;
  padding: 0;
}

div {
  width: 100%;
  height: 100px;
  background: red;
  font-size: 40px;
  line-height: 100px;
  color: #fff;
  text-align: center;
}

.div1 {
  margin: 0 auto 0;
}

.div2 {
  background: green;
  float: left;
  width: 50%;
}

.div3 {
  background: blue;
  float: left;
  width: 50%;
}

<div class="div1">1</div>
<div class="div2">2</div>
<div class="div3">3</div>
Copy the code

Two, nine grid

  1. CSS to achieve adaptive nine grid layout
  2. CSS layout – Nine grid layout method summary

3. Waterfall flow layout

To be added

The title

Implement a vertically centered div 10px to the left and right of the screen, always 50% of its width. At the same time, div has A text A, which needs to be centered horizontally and vertically.

//calc and vw * {padding: 0; margin: 0; } html, body { width: 100%; height: 100%; } .wrapper { position: relative; width: 100%; height: 100%; } .box { margin-left: 10px; /* width: calc(100vw-20px); /* width: calc(100vw-20px); /* width */ height: calc(50vw-10px); position: absolute; background: red; /* Top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; font-size: 20px; }Copy the code
<div class="wrapper">
  <div class="box">A</div>
</div>
Copy the code