2

I'm writting a application by Node.js,express.js,ejs....

I'm using this code to use ejs and load css:

app.engine('.html', require('ejs').__express);
app.set('views', __dirname + '/views');
app.set('view engine', 'html');
app.use(express.static(__dirname + '/views'));

This is my dir struct

myapp
--Controller
----admin.js
--db
----db.js
--views
----admin
------user.html
------addUser.html
----css
------style.css
--app.js

Html load css like this

<link href="../css/style.css" rel="stylesheet">

And i had used css for my web. when i use params :

app.get('/admin/users', admin.users);
app.get('/admin/add', admin.add);

url are:

loocalhost:1080/admin/users

loocalhost:1080/admin/add

then my css active. but when i use param:

app.get('/admin/users/add', admin.add);

url is:

loocalhost:1080/admin/users/add

then my css not active.

so how to fix it?? Please help.

1 Answer 1

1

Avoid making your CSS links relative. So specify them like so:

<link href="/css/style.css" rel="stylesheet">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.