Design comparison
Solution retrospective
Hello everyone! π
Thanks for checking my solution code to the 3-column preview card component challenge
At my learning process I learned how to use in nth-child in stylesheet in order to use different styles instead creating more classes.
.col:nth-child(1) button {
color: var(--bright-orange);
}
.col:nth-child(2) button {
color: var(--dark-cyan);
}
.col:nth-child(3) button {
color: var(--very-dark-cyan);
}
also I learned how to use in outline method for button activity states, because somehow, using in border method, expanded other elements size.
.col .button:hover {
background: none;
outline: 2px solid var(--background-headings-buttons);
color: var(--background-headings-buttons);
}
I'm happy to see that after 6 challenges I did, the process of coding became faster for me.
Built with
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- Desktop-first workflow
Community feedback
- @VCaramesPosted about 2 years ago
Hey @kirawesh, some suggestions to improve you code:
-
Along with the blank alt tag, you also want to include the aria-hidden=βtrueβ to your car images/icons to fully remove it from assistive technology.
-
The headings are being use incorrectly. For this challenge, each heading is equally as important. So best option, is to use <h2> Heading, because it will give each card the same level of importance and it's reusable.
-
Your "buttons" were created with the incorrect element. When the user clicks on the button they should directed to a different part of you site. The Anchor Tag will achieve this.
-
Implement a Mobile First approach π± > π₯
With mobile devices being the predominant way that people view websites/content. It is more crucial than ever to ensure that your website/content looks presentable on all mobile devices. To achieve this, you start building your website/content for smaller screen first and then adjust your content for larger screens.
Happy Coding! π»π
Marked as helpful2@kiraweshPosted about 2 years agoHi @vcarames Thank you for such helpful and detailed feedback!
-
I forgot to fill in the alt tags, this is one of the habits I need to implement immediately. Even so, Aria label's tip is definitely useful, I didn't know that I can do that.
-
I'm not sure why using the tag <h2> is correct. According to the hierarchy, should the tag <h1> not be used? Since there are no subtitles. I'm not sure I understood the explanation well. I would appreciate it if you could explain more about it.
-
You're right, but because it's a challenge, I used the button. Anyway, I switched to a tag to get used to doing it correctly. And now it changed the visibility of the design for me, lol. So I fixed some elements following this.
-
You're right about mobile first approach, but why not to start with desktop approach? It's really makes such big difference? If my content isn't looks presentable well on mobile website, I'd love to know about it.
0@VCaramesPosted about 2 years ago@kirawesh
Glad I could help!
Since this a component, it would be part of a larger site with lots of sections and components, so it would be an <h3> or even <h4>.
But for this challenge, by giving one of the headings the <h1> heading you are stating that heading is more important than the others. By instead using the, next level heading, <h2>, all the headings now have the exact same level of importance.
As for mobile-first approach, mobile devices are the now dominant way in which users are now browsing the internet.
Unlike, computer monitors, which only have a few different screen sizes (but most of the time our content will look the same regardless on large screens), the difference in mobile device screen is countless.
Think of the different screen sizes and ratios that mobile devices have,(think Samsung Fold, Samsung Flip, etc, iPhone mini...), so while your content may look good in certain device size, it may look warped, broken or just does not accommodate the screen. By implementing the mobile first approach, you can ensure your content looks perfect in all screen sizes.
Most importantly, it is best practice.
Marked as helpful1@kiraweshPosted about 2 years ago@vcarames I see, thank you for your explanation. I will try now mobile-first approach on the same challenge to see the differences.
0 -
- @correlucasPosted about 2 years ago
πΎHello @kirawesh, Congratulations on completing this challenge!
Great code and great solution! Iβve few suggestions for you that you can consider adding to your code:
1.You made your html structure entirely with
div blocks
but these div doesn't any semantic meaning, for this reason is better you use a better html markup improving your code, for example for each vehicle card you use<article>
instead of the<div>
.2.Your solution seems fine, you did a really good job wrapping the content for these 3 cards. Something you can improve here is to use a
single class
to manage the content that is mostly the same for the 3 cards (paddings, colors, margins and etc) and another class to manage the characteristics that are different (colors and icon), this way you'll have more control over then and if you need to change something you modify only one class.3.Create the mobile version with a media query:
@media (max-width: 500px) { .columns { display: grid; grid-template-columns: 1fr; } }
βοΈ I hope this helps you and happy coding!
Marked as helpful1@kiraweshPosted about 2 years agoHi @correlucas
Good to hear from you.
-
You are right about the correct use of tags, I still don't really understand how to use them correctly when it comes to a product that is not exactly according to the standards and it is not so clear how to tag it.
-
You are right, I need to rethink the design as a system, instead of a specific element. I remaking this challenge again with mobile-first approach, so I'll figure out how to set up the appropriate classes.
-
How did I miss this, thanks for bringing it to my attention :)
0 -
- @miranleginPosted about 2 years ago
Hi Kira,
congratulations on completing this challenge!
Getting faster and more confident is a nice feeling isn't it?
Now let's get back to feedback. I won't go into semantics because previous poster reviewed that part. The part i'm most interested is the CSS and i think there are some improvements to be made there.
- line 44 of style.css has some invalid properties which can be inspected in Dev Tools, this is on
.columns
declaration. - you have used
border-radius
on a single .col elements and make your job more difficult and styles harder to mantain, you can instead put all rounded corners on parent div.columns
because no matter what the direction on the cards is they will always have all four corners rounded, also you need to applyoverflow:hidden
on a parent to stop children's background to spread outside of the corners - most of the spacing here on the platform is based on a 16px value which is 1rem by browsers default, you can apply that logic when dealing with margin/padding spacing stuff, if it's 24 it is 1.5rem/em, 32 is 2rem/em etc. I found the best way to use rem's for applying layout stuff and spacing around text is easier with em because it is calculated based on font size of an element. For example: h1 has a font-size of 24px, and margin bottom of 12px, if your h1 grows on the larger viewport you need to manually enlarge the bottom margin. if you use 1.5rem as a base font size, and put 0.5em as a margin top, when you enlarge you font-size margin will always be 50% of that font size because em is relative to the element's font-size.
- i've noticed that you declared your custom properties with this naming convention:
--lexend-deca: 'Lexend Deca', 'sans-serif'; --big-shoulders-display: 'Big Shoulders Display', 'sans-serif';
this is somehow limited because if font is about to be changed you would also need to change the name to because it doesn't make any sense to have custom property
--lexend-deca
which points toopen sans
font for instance. that way you are playing cat and mouse because now you have to replace all the instances of this font throughout the whole stylesheet and you made yourself a recipe for disaster. Better way would be to name it like a--font-base
with--font-heading
for example. 5. also i would suggest to take a look at some of the modern CSS resets to just have a clean start each time, you can adjust it to your needs later if you need to or add couple of things if you find necessaryBoth of them did a great job with explaining all the individual rules they created so check them out!
Keep coding and see you on another challenge!
Cheers, Miran
Marked as helpful1@kiraweshPosted about 2 years agoHi @miranlegin,
Thanks for the helpful and detailed feedback. Really appreciate it. I definitely agree with you that it's a wonderful feeling to code faster and being more confident :)
1.I'm not sure I understand what you mean.
I use this to define the columns structure:
.columns { display: grid; grid-auto-flow: column; grid-template: 1fr repeat(3); }
I would appreciate it if you could elaborate on that. and how you use with Dev tools?
-
You're right. I used this at first on the main container, but for some reason it didn't work. I've also used his children, and it still doesn't work. And I have no idea how to solve it other than what I did now. This very strange.
-
Agree with you, I need to implement the habit to adjust units as well. I come from design approach, so I need to switch to coding approach :)
-
That's really a better way to go about custom properties. Thanks for enlightening me on this and for useful links. Already implemented them as custom snippets :)
0@miranleginPosted about 2 years ago@kirawesh
Hi Kira, i guess i didn't make myself clear enough first time so i will try to be more precise. Right now you have this in your style.css file:
.columns { display: grid; grid-auto-flow: column; **grid-template: 1fr repeat(3);** }
That bold statement is invalid for a couple of reasons, first you are declaring it in a wrong way. More info about grid-template Second you value is not valid either. Instead of writing:
grid-template: 1fr repeat(3);
it should be
grid-template-columns: repeat(3, 1fr);
Regardless of that typo the grid is working because you have declared these line, which says that grid should create columns for how much children elements there is.
grid-auto-flow: column;
In case you wanted the grid to have only 3 columns these than you would need to include also:
grid-template-columns: repeat(3, 1fr);
Then in the end complete declaration would be:
.columns { display: grid; grid-template-columns: repeat(3, 1fr); }
The slight difference is that here you are explicitely saying that you want exactly 3 columns, and in your case if you add more items they will just create another columns to the right. Best way is to try yourself and see what you will get.
Hope that makes sense now.
Keep coding!
Cheers, Miran
Marked as helpful0@kiraweshPosted about 2 years ago@miranlegin oh my gosh, you're right! I rely too much on the validity of vscode rather than checking myself whether it is even logical and correct to write this way, lol. Thanks for the important explanation :)
1 - line 44 of style.css has some invalid properties which can be inspected in Dev Tools, this is on
Please log in to post a comment
Log in with GitHubJoin 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