0

My web application currently lists content like this:

current state

I used Microsoft Paint to render what I WANT it to looks like here:

enter image description here

I attempted to create a "grid inside of a grid" but failed miserably and I'm hoping someone can assist me. I'm guessing that I might be able to use flexbox to achieve the desired result, but I am not entirely sure. I'm also not sure how to group the content into individual "cards". Doing so would make things a bit more organized, I think.

The following is my CSS code:

body {
  display: grid;
  grid-template-areas:
    'header header header'
    'nav article ads'
    'nav footer footer';
  grid-template-rows: 80px 1fr 70px;
  grid-template-columns: 20% 1fr 15%;
  grid-row-gap: 1px;
  grid-column-gap: 1px;
  height: 100vh;
  margin: 0;
}

a {
  color: #0ad05b;
  text-decoration: none;
}

a:hover {
  color: #e3eaee;
}

header {
  padding: 1.2em;
  background: #21313c;
  font-family: Helvetica, Arial, sans-serif;
  color: #e3eaee;
}
footer,
article,
nav,
div {
  padding: 1.2em;
  background: #061621;
  font-family: Helvetica, Arial, sans-serif;
  color: #e3eaee;
}
textarea {
  font-family: Arial, Helvetica, sans-serif;
}
#pageHeader {
  grid-area: header;
}
#pageFooter {
  grid-area: footer;
}
#mainArticle {
  grid-area: article;
}
#mainNav {
  grid-area: nav;
}
#siteAds {
  grid-area: ads;
}
/* Stack the layout on small devices/viewports. */
@media all and (max-width: 575px) {
  body {
    grid-template-areas:
      'header'
      'article'
      'ads'
      'nav'
      'footer';
    grid-template-rows: 80px 1fr 70px 1fr 70px;
    grid-template-columns: 1fr;
  }
}
.big-user-photo {
  border-radius: 50%;
}
.userAvatar {
  height: 3.5rem;
  width: 3.5rem;
  border-radius: 50%;
  margin-right: 1rem;
}
.mainPage {
  height: 3.5rem;
  width: 3.5rem;
  border-radius: 50%;
  margin-right: 1rem;
}

The relevant jade code is here:

extends base
block content
    article#mainArticle
        each ship in ships
            .innerArticle
                img.mainPage(src=`/img/ships/${ship.shipPhoto}`, alt=`${ship.shipName}`)
                p Ship: #{ship.shipName}
                a(href=`/ship/${ship.slug}`) See Reviews
Graham
  • 7,431
  • 18
  • 59
  • 84
Chris Clark
  • 488
  • 2
  • 19
  • This post may help you https://stackoverflow.com/questions/17217766/two-divs-side-by-side-fluid-display – shaangon Oct 08 '20 at 14:44
  • 1
    Are you just wanting the cards to line up in a row or are you also wanting the white text and green text to line up too? – Pete Oct 08 '20 at 14:51
  • @Pete, I want the photo, the white text, and the green text to be grouped into individual cards. There would be 3 total cards in the first picture. 20 total cards in the second picture. When I add a new card, I want it to fill the screen going from left to right, adding a new row as needed. – Chris Clark Oct 08 '20 at 14:58
  • 1
    ok so on your card container you can just use flex: `display:flex; flex-wrap:wrap;` and it should put your cards on one row until it runs out of space and then start on the next row – Pete Oct 08 '20 at 15:05
  • @Pete - that worked perfectly, you are the man! Thank you!!! – Chris Clark Oct 08 '20 at 15:15
  • @Pete - do you happen to know what element I can use to adjust the spacing between rows? – Chris Clark Oct 08 '20 at 15:19
  • 1
    margin bottom on your cards – Pete Oct 08 '20 at 15:20

0 Answers0