Submitted over 1 year ago
3-column-preview-card-component-main-CSS3-Flex
@Martin-00789
Design comparison
SolutionDesign
Solution retrospective
Feedback welcome. Thanks for taking the time.
Community feedback
- @0xabdulkhaliqPosted over 1 year ago
Hello there π. Congratulations on successfully completing the challenge! π
- I have other recommendations regarding your code that I believe will be of great interest to you.
CSS π¨:
- Looks like you declared each background color for each button which needs to be change the background color during the hover, actually we can handle that issue with a css color function named
rgba()
- The
rgba()
function define colors using the Red-green-blue-alpha (RGBA) model. RGBA color values are an extension of RGB color values with an alpha channel, which helps us to take control over the opacity of the color.
- So just add
rgba(0,0,0,0)
for thebutton
elements duringhover
- Let's look an example
button:hover { background-color: rgba(0,0,0,0); color: var(--veryLightGray); cursor: pointer; border: 2px solid var(--veryLightGray); }
- Now you can remove these individual declarations for the background for each
button
element
#sedans-btn:hover { background-color: var(--brightOrange); color: var(--veryLightGray); } #suvs-btn:hover { background-color: var(--darkCyan); color: var(--veryLightGray); } #luxury-btn:hover { background-color: var(--veryDarkCyan); color: var(--veryLightGray); }
- Now you have gotten the desired result without hassling in an efficient way.
- Pro tip: you can use
transparent
value forbackground
property to get the same effect asrgba(0,0,0,0)
but usingrgba
provides more granular control over the color correction.
.
I hope you find this helpful π Above all, the solution you submitted is great !
Happy coding!
Marked as helpful0 - @fernandolapazPosted over 1 year ago
Hi π, in case you want to take a look:
HTML / ACCESSIBILITY:
- The main content of every page (the card in this case) should be wrapped with the
<main>
tag.
- Every page should have an
<h1>
to improve user experience and because it is an important element when it comes to SEO. Maybe it could be added at the beginning of the page and hide it with CSS for example.
- The icons are decorative images and therefore need an empty
alt
attribute to be ignored by a screen reader.
- Remember that
<button>
should be used for any interaction that performs an action on the current page and<a>
should be used for any interaction that navigates to another view. It seems that links are more appropriate in this case.
CSS:
- The page content could be centered using Grid or Flexbox. For example as follows:
body { min-height: 100vh; display: grid; place-content: center; }
- You might consider using relative units like rem or em since they are better for scalable layouts. Something simple to start with would be to convert to rem (1 rem equals the font size of the root element, 16px by default). Consider this suggestion especially for the
font-size
.
I hope itβs useful : )
Regards,
Marked as helpful0 - The main content of every page (the card in this case) should be wrapped with the
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