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
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>
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With