Design comparison
Solution retrospective
What is the best way in CSS to have variable(a) hold a hsl value, and another variable (b) hold variable (a) value with opacity added to it?. Thanks in advance.
Community feedback
- @BoyutifePosted over 1 year ago
Hi Victor Durodola π. Congratulations on successfully completing the challenge! π
I have some additional suggestions for your code that I believe will be of great interest to you.
HTML π·οΈ:
-Ensure headings are in a logical order. For example, check that all headings are marked with h1 through h6 elements and that these are ordered hierarchically. For example, the heading level following an h1 element should be an h2 element, not an h3 element. Finally, don't use heading mark up on text that isn't actually a heading.
-This solution generates accessibility error reports, "All page content should be contained by landmarks" is due to non-semantic markup, which lack landmark for a webpage. To address this issue, you can review the HTML code of the webpage and add appropriate landmarks where necessary. Some common landmarks that you may want to consider including are: <header> <main> <section> <aside> instead of multiple <div> <span>
CSS π¨: In response to your question
:root { --a: hsl(240, 100%, 50%); }
Then, you can use this variable to define another variable with opacity added to it, like this:
:root { --a: hsl(240, 100%, 50%); --b: hsla(var(--a), 0.5); }
Here, the hsla() function is used to add an opacity value of 0.5 to the --a variable.
You can then use the var() function to reference these variables in your CSS styles:
.some-class { color: var(--a); background-color: var(--b); }
I hope you find this helpful π Above all, the solution you submitted is great !
Happy coding!
1
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