Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Testimonials Layout using CSS Grid + Flex

P
Andy 140

@AStombaugh

Desktop design screenshot for the Testimonials grid section coding challenge

This is a solution for...

  • HTML
  • CSS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


What are you most proud of, and what would you do differently next time?

Despite a lot of struggling, I did finish the project and it looks...somewhat like the mockup. I am not well-versed with Grid yet and it shows. I think I made quite a few errors, but I stuck with it and finished and that's what I'm most proud of. While I did not have access to the tablet mockup, I did try to make sure the grid reduced appropriately regardless.

What challenges did you encounter, and how did you overcome them?

Working with the grid attributes to get the layout correct. This is the first time I've ever attempted this style of layout and it was very frustrating. I relied heavily on the browser inspector to give me a more visual idea of what was happening with my code as I was coding. The rulers and grid section numbering inside of Chrome's inspector was invaluable to this project, but also shows that I just don't have the experience with Grid yet to feel confident in doing it and doing it well.

What specific areas of your project would you like help with?

  1. What could be refactored in my CSS to make it simpler? I tried combining as much code as I could and ultimately found that I was overwriting myself as I was doing it which results in me splitting EVERYTHING into classes so I could better track where I was getting stuck. My primary cards have a total of three classes on just the top level card and that seems excessive.

  2. On desktop, what could I do to improve the handling of the grid layout? It feels very clunky to me. I'm not sure if that's just my lack of understanding the concepts of Grid or if I'm overthinking it. Realistically I would have liked this to reduce from desktop to mobile and back again with a little less reliance on media queries, but as I worked through this I genuinely could not figure out a way to make that possible. It feels like grid is intended to be very precise whereas flex allows you to utilize percentages and math to scale responsively.

Community feedback

Alex 3,130

@Alex-Archer-I

Posted

Well, I totally understand your frustration with grid, but just like at your last challenge you really did it right now! That is the power of grid - you create, well, grid, and just tell the elements which cell they should take. That's really powerful and convenient. To achieve the same result with flex you would have to put divs into divs inside divs...

You even can omit grid-template-row on the mobile version as grid create additional rows on the fly.

Speaking about classes - templates like this a good way to get familiar with naming conventions. Did you already hear about them? I mean BEM, OOCSS, SUITCSS SMACSS (though the last one for big sites with different areas).

When I was working on this challenge I used BEM-like approach. I created a four modifier classes represented color themes.

.testimonials__item--purple {
    position: relative;
    background-color: var(--moderate-violet);
    color: var(--white);
    --border-color: hsl(262, 40%, 82%);
}
.testimonials__item--gray {
    background-color: var(--very-dark-grayish-blue);
    color: var(--white);
    --border-color: var(--white);
}

.testimonials__item--white {
    background-color: var(--white);
    color: var(--very-dark-grayish-blue);
    --border-color: var(--white);
}

.testimonials__item--dark {
    background-color: var(--very-dark-blackish-blue);
    color: var(--white);
    --border-color: var(--moderate-violet);
}

As you can see they have color property which is inherited one. So I didn't have to apply color for text inside them. Also I declared variables for color of image border here.

Definitely learn about different naming approaches and don't be afraid of long classes - it could be helpful especially if you can reuse them.

So, you really did it great (especially for a guy annoyed by the grid) =)

And I know, you'll hate me for this... but lists, dude, lists...

Marked as helpful

1

P
Andy 140

@AStombaugh

Posted

@Alex-Archer-I I saw somebody mention BEM a solution they submitted for the last challenge but I didn't quite understand it. I should probably spend more time learning it so others can better read my code, however. I don't want to make it harder for people to help me improve with code that only really makes sense to me.

I swear I started with lists on this project! I got to a point where some of my styles weren't applying and when I switched from using lists to articles my styles were applying correctly. I thought maybe the lists had something to do with it which is why I made the switch about midway through my project. :|

1
Alex 3,130

@Alex-Archer-I

Posted

@AStombaugh

Sorry about list thing =) I wonder why they didn't work. Alas, I can't figure out what the reason was, but I doubt that it was list issue.

The things like BEM are very useful not only for others to better understand your code (your code is clean though, besides it's always possible to inspect it through dev console). But different naming approaches could help you improve, well... mindset? way of thinking?... I mean it helps you to figure out how to apply styles more effective and convenient. But be prepared to more frustration =) It is something you could grasp only with practice =)

I'm just now starting to understand the nuances of some approaches even already practice them.

Guess you already knew that, but fell free to ask anything if you need =) Here, or you can reach me on discord - archerthecat0851.

1
Alex 3,130

@Alex-Archer-I

Posted

@AStombaugh

Oh, by the way, even without BEM you could do this to reduce CSS:

.violet h2,
.violet h3,
.violet h4 {
  color: var(--light-grayish-blue);
}
1

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord