如何在python flask中的css中指定图像的位置

I'm trying to make a website in flask and I want to put an image on the website it works using the img tag but I cannot resize or do anything to it. I want to use it as a background and want it to be responsive but I can't, the css files can't find the specified image. Here is the code Thanks in advance.

评论
  • 纠结
    纠结 回复

    Seems you have the below project directory for the static folder:

    static/ └── css/ └──style.css └── img/ └──image.png

    If you are using the above directory structure you can use the below CSS commands in CSS file:

    background: url(../img/image.png)no-repeat 0px 0px;
    background-size: cover;
    

    This will import the image from static/img/ and then you can all the CSS tag to make it responsive.