尽管使用了正确的机制,但我无法将不同目录中的样式表连接到我的 HTML 文件。我的目标水平是否正确?
'-'表示级别
这是我的文件结构:
我的元素(父级)
-公共(public)(第一级)
--样式表(二级)
---styles.css(第三级)
- View (第一级)
--index.ejs(二级)
HTML:
<!doctype html>
<html>
<head>
<title>Node Authentication</title>
<link rel="stylesheet" type="text/css" href="../styles.css">
</head>
最佳答案
假设您在应用中以这种方式使用 Express Static
中间件:
app.use(express.static(__dirname + '/public'));
那么在你看来:
<!doctype html>
<html>
<head>
<title>Node Authentication</title>
<link rel="stylesheet" type="text/css" href="stylesheets/styles.css">
</head>
关于HTML 无法在不同的目录中找到样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24521134/