简体   繁体   中英

Flask and css reference to static files

I have a basic flask app, where I reference background images in my css file like this

.three {
  background:url('/static/images/house.jpg');
}

My folder organization is like this:

project
    app.py
    -static
        -images
            house.jpg
        -css
            index.css
    -templates
        index.html

How do I get my css to properly call the image?

change your css to this, and then try again:

.three {
  background-image: url('images/house.jpg');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM