Adding the CSS
✍️ Objective - To add design to the category divs
Open the layout.css file, you would be seeing some existing code in it, for now you can ignore it.
Let's add the following css to the end of layout.css file
This CSS code snippet provides styling for the category card HTML structure. The main container is a flex container with horizontal scrolling enabled. Each category card has a fixed width, a margin to its right, and some basic styling such as a background color, box-shadow, and border-radius.
Don't remove classnames which start with "dkn-" because they are used by internal functions.
The category link has its text decoration removed and inherits the color from the parent. The category image wrapper has a square aspect ratio and uses the padding-bottom trick to achieve this. The image is positioned absolutely within the wrapper and covers the entire space, maintaining its aspect ratio.
Lastly, the category name has some padding, font size, and font weight adjustments to make it stand out more.
Wohoo! It looks beautiful now, with our CEO Leo lighting up the page with his cuteness. After you've added this, its time to add some functionality to our cards, what if a user clicks on the category card? We could take it to category page, display a message or just shower confetti!
We'll figure it out in the next chapter
Last updated