FrontEndMentor.io Four Card Feature Section Solution: No CSS Grid, Flexbox or Positioning
How I re-created this section of the design challenge
3 min readMar 25, 2020
Spoiler alert: do not read if you haven’t completed the Four Card Feature Section challenge on FrontEndMentor.io
Why this challenge?
- In the slack group’s #help channel, this challenge gives people the most pause
- Amongst the solutions featured on the website are many using CSS Grid, Flexbox and absolute positioning
- My gut was telling me there must be an easier way…and there is!
Hint: the answer is in the challenge description
My solution: using multi-column layout
First, the HTML
<ul class="card-group">
<li class="card">
<h2>Supervisor</h2>
<p>Monitors activity to identify project roadblocks</p>
<div class="icon"></div>
</li>
<!-- three more -->
</ul>
- An unordered list with four list items
- Three classes:
card-group
,card
andicon
- Each list item contains three elements, a level-2 heading, a paragraph, and in this case a placeholder to simulate the icon
Let’s build up the CSS to fully understand what each property: value
pair has on the layout.
.card-group {
list-style: none;
margin: 0;
padding: 1rem;
font-family: sans-serif;
}
.card-group {
list-style: none;
margin: 0;
padding: 1rem;
font-family: sans-serif;
column-count: 3;
}
.card-group {
list-style: none;
margin: 0;
padding: 1rem;
font-family: sans-serif;
column-count: 3;
column-gap: 3rem;
}
.card {
display: inline-block;
}
.card {
display: inline-block;
box-shadow: 0 7px 16px #d7e0ea;
border-radius: 6px;
border-top: 5px solid black;
padding: 1rem;
margin-bottom: 3rem;
}
.card:nth-child(3n + 1) {
display: block;
}
.card:nth-child(3n + 1) {
display: block;
transform: translateY(50%);
}
.icon {
width: 80px;
height: 80px;
background-color: black;
}
.icon {
width: 80px;
height: 80px;
background-color: black;
margin-left: auto;
}
Layout re-creation successful using multi-column
- No need for CSS Grid and the HTML it would require
- No need for CSS Flexbox and the HTML it would require
- No need for absolute and relative positioning
- The real heroes of this solution are four CSS property:value pairs and a pseudo-selector!