1

Newbie question as stated above. How do I access the public folder of laravel in .css file? I have a custom css and I want to get the url of the image.

2 Answers 2

1

You can not use the asset() or public_path() functions there, they will not get called from a css file but you can use the traditional way to access file like this

../css/want_to_import.css

This is the only way you can access a file in a css file, unless you're writting your css dynamically then possibilities are different.

Sign up to request clarification or add additional context in comments.

Comments

0

If your domain points to your public folder, you can reference it using /

Let's imagine you want to display a JPG file as a background image.

public/image/background.jpg

In your CSS, you can use background-image:url('/images/background.jpg')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.