Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background Image example does not work #15858

Closed
timgavin opened this issue Jan 24, 2025 · 3 comments
Closed

Background Image example does not work #15858

timgavin opened this issue Jan 24, 2025 · 3 comments

Comments

@timgavin
Copy link

The background image example shows a relative URL, however, after many trials & tests I have only been able to get the bg-[url()] utility to work with a full URL.

// does not work
bg-[url(/img/mountains.jpg)]
// does work
bg-[url(https://tailwind4.test/img/mountains.jpg)]
@eliooooooo
Copy link

Hello,
This works fine for me.

I tried it in a new project and was able to use bg-[url(/img/mountains.jpg)] to display a background image, positioned in the root directory.

Perhaps this is a problem with your link?

@timgavin
Copy link
Author

I tried this in a Laravel app that I upgraded, and since I couldn't get it working (figured I was doing something wrong) I created a new Laravel install using Herd (followed the instructions from Tailwind's docs to be sure) and was still not able to see the image using a relative URL. I was able to use style="background: url('/dark.jpg')" in the same div, and I saw the image, so I know the link is valid.

@rozsazoltan
Copy link

Both work:

https://play.tailwindcss.com/o7ZeciLw6x

@adamwathan adamwathan transferred this issue from tailwindlabs/tailwindcss.com Jan 25, 2025
@tailwindlabs tailwindlabs locked and limited conversation to collaborators Jan 25, 2025
@adamwathan adamwathan converted this issue into discussion #15859 Jan 25, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants