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

Struggling to place 2 Divs on the same line with Grid Template

Basically I am trying to recreate this image:

https://imgur.com/a/OcgGfmn

But struggling on the LightBlue and Red section on putting them on the same line:

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

 .sidebar {
    background-color: lightblue;
    width:20%;
    min-height:100px; 
}
.content {
    background-color: red;
    width:80%;
    min-height:100px;
}

So far I have tried Flex, inline-block and changing the widths, but cannot seem to get them from not appearing under each other

Inmy container I have:

.container {
    display:grid;
    grid-template-areas: 
    "navbar navbar navbar navbar"        
    "sidebar content"
    "footer footer footer footer"
}

>Solution :

See below. Using grid-area for all relevant classes and width removed for sidebar and content.

.navbar {
  grid-area: navbar;
  background-color: lightgreen;
}

.sidebar {
  background-color: lightblue;
  min-height: 100px;
  grid-area: sidebar;
}

.content {
  background-color: red;
  min-height: 100px;
  grid-area: content;
}

.footer {
  grid-area: footer;
  background-color: lightgreen;
}

.container {
  display: grid;
  grid-template-areas: "navbar navbar navbar navbar" "sidebar content content content" "footer footer footer footer"
}
<div class="container">
  <div class="navbar">navbar</div>
  <div class="sidebar">sidebar</div>
  <div class="content">content</div>
  <div class="footer">footer</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