Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to divide css grid like first column 50%, second column 50% and third column 100%?


    .main-dev {
        display: grid;
        grid-template-columns: 50% 50%;
    }

I want to arrange my grid into 50% 50% and 100% structures. I have attached the required output image.

Current output :

Grid in four box

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Expected Output :

Grid device in 50% 50% and 100%

>Solution :

CSS:

.item{
    border: 1px solid red;
    text-align: center;
    padding: 10px;
}
.main-dev {
    display: grid;
    grid-template-columns: 50% 50%;
    width: 200px;
}
.item3{
    grid-column: 1 / 3; /* or grid-column: 1 / span 2 */
}

HTML:

<div class="main-dev">
  <div class="item">1</div>
  <div class="item">2</div>
  <div class="item item3">3</div>
</div>

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading