If you would like to flex grid 2 columns in CSS then you need three (3) divs.

Step 1 – Set your HTML template

Create some HTML with this layout.

1
2
3
4
5
6
7
8
<div class="Parent">
  <div class="child1">
      <h1>Left</h1>
  </div>
  <div class="child2">
      <h1>RIGHT</h1>
  </div>
</div>

Step 2 – Container Div

Create a Parent div that uses the Flexbox display model.

1
2
3
4
.Parent {
  display: flex;
  flex-direction: row;
}

Step 3 – Child Divs

Create two (2) divs that are both 50% of the parent container.

Below we set the height to 100% of the viewport height.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
.child1 {
  width: 50%;
  height: 100vh;
  background-color: green;
}

.child2 {
  width: 50%;
  height: 100vh;
  background-color: red;
}

Step 4 – Some gotchas to be aware of

You should also set the padding and margin to `` to make sure there is no overlap.

1
2
3
4
.body {
  padding: 0;
  margin: 0;
}

It is also good practice to set the border-box as follows:

1
box-sizing: border-box;

A good overall way to set these are as follows:

1
2
3
4
5
* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}