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 get this flex layout without editing the HTML structure?

This is the layout I’m trying to achieve with CSS:

enter image description here

And this is the HTML structure I have and can’t touch at all, and what I’ve managed to add with CSS. It’s close but something is missing:

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

.container {
  display: flex;
  flex-wrap: wrap;
}

.item-1 {
  flex: 50%;
}

.item-2 {
  flex: 50%;
}

.item-3 {
  flex: 100%;
}
<div class="container">
  <div class="item-1">
    This is an image
  </div>
  <div class="item-2">
    This is a title
  </div>
  <div class="item-3">
    Short desc goes here.
  </div>
</div>

How do I fix this? Thank you!

>Solution :

In case you’re looking for a grid solution:

.container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /*two equal width columns.*/
  grid-template-rows: auto auto;
  /* two rows with auto height. */
  grid-gap: 10px;
}

.item-1 {
  grid-row: 1 / 3;
}

.item-2 {
  grid-row: 1 / 2;
}

.item-3 {
  grid-row: 2 / 3;
  grid-column: 2 / 3;
}
<div class="container">
  <div class="item-1">
    This is an image
  </div>
  <div class="item-2">
    This is a title
  </div>
  <div class="item-3">
    Short desc goes here.
  </div>
</div>
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