Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split a div into multiple rows and columns in css?

I have div subdiv inside maindiv. I want to make the sub div into multiple rows and columns as below.

How to divide the subdiv as below

enter image description here

like image 228
rji rji Avatar asked Dec 09 '22 04:12

rji rji


2 Answers

You can do something like this

div{
  display:inline-block;
  float:left;
  color:#fff;
  font-size:40px;
}

.one{
  width:150px;
  height:200px;
  background:red;
}

.two{
    width:100px;
  height:200px;
  background:lightgreen;
}

.three{
    width:100px;
  height:200px;
}

.four{
  width:100px;
  height:100px;
background:darkblue;
}
.five{
  width:100px;
  height:100px;
background:blue;
}
<div class="one">1</div>
<div class="two">2</div>
<div class="three">
  <div class="four">4</div>
  <div class="five">5</div>
</div>
like image 195
Suresh Karia Avatar answered Jan 08 '23 03:01

Suresh Karia


I know that the question has been answered but there is another way to do this.

You can Achieve it using css grid. read more about css grid

.grid { 
    display: grid;
    grid-template-columns: 10rem 7rem 7rem 7rem;
    grid-template-rows: 7rem 7rem;
    grid-template-areas: 
    "s1 s2 s3"
    "s1 s2 s4"
}
.s1 { 
    grid-area: s1;
    background-color: #FF0000;
}
.s2 { 
    grid-area: s2;
    background-color: #00FF36;
}
.s3 { 
    grid-area: s3;
    background-color: #0030FF;
}
.s4 {
    grid-area: s4;
    background-color: #FF00E4;
}
 <div class="grid">
      <div class="g s1"></div>
      <div class="g s2"></div>
      <div class="g s3"></div>
      <div class="g s4"></div>
 </div>
like image 25
Kareem Dabbeet Avatar answered Jan 08 '23 02:01

Kareem Dabbeet