Why not try CSS grid?
One efficient way to achieve this is by utilizing CSS grid
, which also ensures responsiveness.
Utilizing the CSS property grid-column
This particular property acts as a shorthand for both grid-column-start
and grid-column-end
Check out more details: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column
By using Firefox DevTools, you can simply click the grid button within the code to make a visualizer appear...
During my exploration, I discovered that creating a 4 column grid layout was the most effective approach.
If you want to explore further, here's the code :)
body {
display: grid;
place-content: center;
height: 100vh;
}
.container {
display: grid;
gap: 0.5em;
height: 80vh;
width: 80vw;
}
.container .child {
background: lightblue;
display: grid;
place-content: center;
}
.child1 {
grid-column: 1/2;
grid-row: 1/3;
}
.child2 {
grid-column: 2/4;
}
.child3 {
grid-column: 2/3;
}
.child4 {
grid-column: 3/4;
}
<!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>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="child child1">col1</div>
<div class="child child2">col2</div>
<div class="child child3">col 2.1</div>
<div class="child child4">col 2.2</div>
</div>
</body>
</html>