Tailwind CSS

Solution retrospective
Hi, I used this challenge to learn tailwind css. I struggled with the background image thing, it looks like the same background image is used twice but the second time it roated horizontally and vertically both. How do I get the background pattern as its in the challenge?
Please log in to post a comment
Log in with GitHubCommunity feedback
- @adityaphasu
Hello!
The issue you are experiencing is due to the background image repeating. By default, a background-image is repeated both vertically and horizontally therefore to avoid this generally in CSS
background-repeat:no-repeat
is used but since you are using tailwind you can addbg-no-repeat
to the div.- You can add
bg-[hsl(225, 100%, 94%)]
(this is the pale blue color from the style guide) which will also apply a background color so it matches the design.
Few tips while for tailwindcss to use upon the next project:
- Instead of using inline style to add the background images using tailwind you can actually
use the
tailwind.config.js
to add those images and use them simply using tailwind classes. This is how you do it:
module.exports = { theme: { extend: { backgroundImage: { "desktop-pattern": "url('/images/pattern-background-desktop.svg')", "mobile-pattern": "url('/images/pattern-background-mobile.svg')", } } } }
- After adding these you can in the html file just use
bg-desktop-pattern
orbg-mobile-pattern
and the background image would get applied! - You can actually do the same thing for colors and various other properties as well. The config file is there to add custom values so that we can use them in a tailwind fashion.
- Here give this page a read from docs to know more about it!
Keep up the hard work and happy coding!🙂
Marked as helpful - You can add
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