0

I know similar questions have been answered but there are no clear answers for how to do this in a linked css file, all suggest doing directly in the html file itself I have a Jobs project, with the following structure to get to the images folder:

Jobs/core/static/core/images/search.jpg

How can I set an input element's background-image property to 'search.jpg' in a css file that is referenced with <link rel="stylesheet" href="{% static 'core/css/index.css' %}" /> ? I have seen similar questions asked and all of the answers suggest things such as setting it inline on the element itself, but how can this be done in a linked css file?

1 Answer 1

2

Django cant see or write CSS files, all your CSS that needs Django static import you should put it inline (i like to create a new html files with my inline css with static urls and than include it on my template)

<div style="background-image: url({% static 'core/images/search.jpg' %});" />

Or you can use relative paths in your css files, but this will probabily give you a headache when start to setup in production

.someClass {
   background-image: url(/static/core/images/search.jpg);
}
Sign up to request clarification or add additional context in comments.

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.