CSS boxes layout query

Issue

I need css styling help. Layout should be as follows.

  1. Heading block covers the entire row
  2. 2nd row => Two blocks with same height and share 80%-20% width side-by-side and second block should have two blocks inside vertically stacked.
  3. 3rd row => two blocks with same height and share 50-50
  4. a big heading

I tried like this

  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  height: 900px;
  position: absolute;
}
.cell {
  border: solid 3px black;
}
.cell-1 {
  width: 1500px;
  
}

.cell-2 {
height: 450px;
width: 20%;
}

.cell-3 {
height: 450px;
width: 20%;
}

.big-container {
display: fixed;
flex-direction: row;
flex-wrap: wrap;
position: relative;
}

.container-2 {
display: inline-block;
flex-direction: column;
flex-wrap: wrap;
height: 100px;
position: absolute;
}

.container-3 {
display: flex;
flex-direction: column;
flex-wrap: wrap;
margin-top: 1300px;
height: 700px;
position: absolute;
}

.cell-2-1 {
margin-right: 300px;
margin-top: 1000px;
text-align: center;
width: 100%
}

.cell-2-2 {
width: 50%;
width:700px;
}

.cell-2-3 {
width: 50%;
margin-left: 200px;
}
<div className="big-container">
                <div className="container-1">
                    <div className="cell cell-1">
                        <Component1 /> (row2-left block)
                    </div>
                    <div className="cell cell-2">
                        <Component2 /> (row2-left block)
                    </div>
                    <div className="cell cell-3">
                        <Component3 /> (row2-right-side bottom block)
                    </div>
                </div>


                <div className="container-3">
                    <div className='cell-2-2'>
                       <Component5 /> (row4-left block)
                    </div>
                    <div className='cell-2-3'>
                       <Component6 /> (row4-right block)
                    </div>
                </div>
            </div>

I somehow achieved it using incorrect way, like adding .container-3 margin-top as 1300 px based on the space occupied by components so far. I would like to know if there is a better and easy to do it

Solution

I think u looking for something like this its hard to figure out cause you have not provided a output expected

body{
  padding: 0;
  margin: 0;
  height: 100vh;  
  Width: 100VW;
  background:#333;
}

.big-container{
  display:flex;
  flex-direction:column;
}

.heading-row , .big-heading{
  width:100%;
  background-color:yellow;
}

.row1 , .row2{
  height:400px;
  display:flex;
}

.row1 .box1{
  width:80%;
  height:100%;
  background:red;
}

.row1 .box2{
  width:20%;
  height:100%;
  background:blue;
  display:flex;
  flex-direction:column;
}

.row1 .box2 > *{
  height:50%;
  width:100%;
}

.row1 .box2 .verticle-box1{
  background-color:green;
}

.row1 .box2 .verticle-box2{
  background-color:pink;
}

.row2 > *{
  height:100%;
  width:50%;
}

.row2 .box1{
 background:orange;
}
.row2 .box2{
 background:purple;
}
<!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>
</head>
<body>
  
  <div class="big-container">
    
    <div class="heading-row">
      <h1>Heading</h1>
    </div>
    
    <div class="row1">
      
      <div class="box1"></div>
      
      <div class="box2">
        
        <div class="verticle-box1"></div>
        <div class="verticle-box2"></div>
        
      </div>
      
    </div>
    
    <div class="row2">
      
      <div class="box1"></div>
      
      <div class="box2"></div>
      
    </div>
    
    <div class="big-heading">
       <h1>Heading</h1>
    </div>
    
  </div>
  
  
  
</body>
</html>

Answered By – Mad max

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published