I have a question about the css background image path.

Asked 2 years ago, Updated 2 years ago, 60 views

Creating page with pug template. I put the jpg image file in the same directory as the pug template file and wrote the code as follows, but no background is specified. What's the problem?

doctype html
html
    head
        style.
            body{
                background-image: url("spring.jpg");
            }

css pug

2022-09-22 14:21

1 Answers

1_Create a subdirectory called image in the project directory, and insert the summer.jpg file that you want to specify as your background.

Write the following code in 2_main.js to specify the directory to use static files.

app.use(express.static('image'))

3_ view.pug uses:

        body {
            background-image: url(summer.jpg);
        }

https://stackoverflow.com/questions/32029461/using-background-images-in-jade/32029529 I figured it out here.


2022-09-22 14:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.