Karam Haj
Karam Haj

Reputation: 1250

nodejs, background-image css doesn't work

quick and simple question, I'm trying to add a div with a background-image in *.ejs page file.

<style>
    .signPage{
        background-image: url("//back.jpg");
        width: 98%;
        height: 98vh;
        top: 1%;
        right: 1%;
        position: fixed;
        border-radius: 20px;
    }

the image and the ejs are in the same directory. thanks

Upvotes: 1

Views: 3726

Answers (2)

Rahul Kakkar
Rahul Kakkar

Reputation: 1

You have to provide the path from the css file in which you have specified the rule.
For example: if the image is in folder public/images
and the css file is in folder public/css,

then you should provide like this
-- ../images/image-name.image-extension

In short - You have to provide a path relative to css to image

Upvotes: 0

Sanjay
Sanjay

Reputation: 1007

you need to first provide a static path in app.js and then put background image at public/images to use it just

background-image: url("images/back.jpg");

app.use(express.static(__dirname+'/public'));

Upvotes: 2

Related Questions