简体   繁体   中英

Css not loading on node.js generated link

I'm using node.js, express and mysql. I have successfully followed these instructions to include my css file: How can I include css files using node, express, and ejs? The css does load on every page, except one link that contains an id in the url:

http://localhost:8089/edit/123

The last number is passed from the previous page, when the user clicks on an 'edit' link in a table row. The styling is not loading on this edit page. It does load everywhere else. My node.js server file:

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

The edit.html is in the same 'views' folder as the other pages. The css link is the same in the html:

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

Can someone help what the problem is and how to fix it?

add /

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

this way it will return to the document root not on here /edit/123/css/style.css

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM