BeldCode
BeldCode

Reputation: 67

Can't change background-image size via css in flask

I have a css file in my static folder, where I set a background-image for a site of my Flask App. However, no matter what I try, it doesn't apply any "size" parameters I insert. It always stays the same! background-size is ignored by the browser. It always looks the same.

In Chrome the image is always too big. In firefox it works correctly. When I press ctrl + plus/minus, the background image gets bigger/smaller in chrome, whereas in firefox it stays the same. What am I doing wrong?

I insert the style.css file in my html-template like that: <link rel="stylesheet" href=" {{ url_for('static', filename='style.css') }} ">

my style.css-file:

body {
    background-image: url("myPicture.jpg");
    background-repeat: no-repeat;
    background-size: cover;
}

Upvotes: 0

Views: 598

Answers (1)

Joost
Joost

Reputation: 3729

The url in the .css file is not pointing towards a valid image file url. Assuming the file is stored in the static folder of your app, you can try:

background-image: url("static/myPicture.jpg");

I'm not sure where the current background image is coming from, we simply don't have enough info to properly debug.

Upvotes: 1

Related Questions