Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help3403


This forum is provided to promote discussion amongst students enrolled in Agile Web Development (CITS3403).
 
Options:
RSS cloud
Jump to:

flask images in css

1 of 419 articles shown, currently no other people reading this forum.
photo
From: Timothy F.
Date: Thu 7th May, 1:18pm
Actions: 
        Login-to-reply

 

"Aditya Gupta" <22*2*0*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> Hi, my question is regarding how to import an image for CSS that is stored in an 'images' 
> folder which is nested in the 'static' folder.
> 
> For example, I want the code in my CSS file to say:
> 
> .intro {
>      background: url(...);
> }
> 
> I have tried using both the normal path technique that is normally used in CSS 
> (/static/images/...) as well as tried using the jinja2 methods that are used in HTML {{ 
> url_for('static', filename='images/...') }}. However, none of my methods have worked so far 
> and I'm not sure why.
> 
> Thanks

jinja is only interpretted server side, not by the browser, so url_for won't work.

css urls are interpreted relative to the location of the css file, so should probably be 
/images/... as the argument for url.

Related articles

flask images in css (both) RSS
├─ original   Wed 6th May, 5:17pm, Aditya G.
└─ THIS   Thu 7th May, 1:18pm, Timothy F.
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  3:57pm Aug 06 2020