Thursday 15 August 2013

node.js - can't load css when param express.js too long -



node.js - can't load css when param express.js too long -

i'm writting application node.js,express.js,ejs....

i'm using code utilize ejs , 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 dir struct

myapp --controller ----admin.js --db ----db.js --views ----admin ------user.html ------adduser.html ----css ------style.css --app.js

html load css this

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

and had used css web. when utilize 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. when utilize param:

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

url is:

loocalhost:1080/admin/users/add

then my css not active.

so how prepare it?? please help.

avoid making css links relative. specify them so:

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

css node.js express params ejs

No comments:

Post a Comment