Responsive 3-column preview card using CSS flexbox
Design comparison
Solution retrospective
I love how I'm improving lately👌😍 but how some things just don't work out is so frustrating and irritating 😒😢
Why doesn't my "color: inherit;" works? I'll really appreciate any help from you guys, much thanks.
Community feedback
- @DimiPavlovPosted over 2 years ago
Hello Garang, congratulation on completing the challenge.
Regards your question about color: inherit not working, I suggest you take a look at the MDN site about the 'inherit' property.
https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
It does inherit the color of the parent element, in your case, that's the sections. If you take a look at your code, you will see that your section has no color property, only a background-color. So you are trying to inherit a color from a background-color, which is not possible. You can add a random color to your sections and see how your button color will also inherit it.
Hope I was able to help you.
Happy coding :)
Marked as helpful0 - @mihalymarcell86Posted over 2 years ago
Hello @Garang-Deng,
the problem with
color: inherit
is that you didn't specify thecolor
property in any of the parent elements of the button, so at the moment it gets its color from the user agent default stylesheet. It won't work between different properties, though. You can't "inherit" the value of abackground-color
property of the parent to become the value of acolor
property in the child element. You can, however, set thecolor
property to the same custom property value you used for your background. In that case both background- and font colors will stay in sync, if you wanted to change them.Hope, this helps! :)
Marked as helpful0
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