3-column preview card component: Mobile first using Flex

Solution retrospective
I had to use !important thrice to force css changes. I'd like some advice on how to make the changes without the important tag.
Please log in to post a comment
Log in with GitHubCommunity feedback
- @RazaAbbas62
Hi, For button you are setting its color on
button a
selector, while for hover you are just usingbutton
, so due to less specificity of button as compared tobuutton a
u need to add important tag.For the width of main, you are using width two times in the same selector , that's why it is causing problem,
And
flex-direction:row
is working fine without important tag.I hope this will help.
Enjoy Coding:)
Marked as helpful - @emestabillo
Hey @DanielleLensly, great job on completing your project! Some recommendations:
CSS:
- add a reset to your stylesheet
- use relative units such as
rem
instead ofpx
- lines 116 and 122 are identical as mentioned previously. So are lines 80 and 141.
- For the width of the cards:
- set a
max-width
inrem
on the main container and - remove all widths and max-widths on the cards. Use padding to keep the content from touching the gutter
- set a
- For centering the component on the page:
- Remove
position: absolute
from main andposition: fixed
fromattribution
. You don’t even needstatic
since that’s the default - use flex (or grid) on the
body
:
- Remove
body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
HTML:
a
tags redirect users to another page/section of a site, which is what we need here. Instead ofbutton
s which perform an action (ex. submitting information or hiding/showing divs)div class="main”
can be replaced by<main>
- Write your markup as if you are writing a word document. There should only be one
h1
(main heading) on a page. There’s no clear heading in the design, but you can add one with thesr-only
class. Check out this article and here's another one for the headings.
Hope this helps!
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