css - Node express + CSS

标签 css node.js express

我正在请求单个 EJS 文件(设置 Express、Request)。

app.get('/space', function(req, res){
    res.render('space.ejs');
});

文件实际呈现,但在使用我的 Node 应用程序打开页面时,三个 CSS 样式表链接中只有两个有效。不起作用的链接是 W3 学校。 (这三个中唯一的 http,这可能是原因吗?) 但是,当我直接在浏览器中打开文件时,所有三个链接都有效。

有人可以解释这种行为吗?

这是.ejs 文件。

<!DOCTYPE html>
<html>
<title>W3.CSS Template</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<html>

最佳答案

您可能正在尝试通过安全连接访问不安全的资源,如果您的站点位于 https 上,则您无法请求 http Assets 。尝试将 w3 链接更改为 https。它也可能被 CORS 阻止,您在控制台中看到任何错误了吗?

关于css - Node express + CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42128201/

相关文章:

jquery - jquery fadeout() 后 Chrome 重绘未正确发生 - 元素保留 Google Chrome 中隐藏元素的高度

node.js - 在 Mongoose 中,如何在具有 .create()、.id() 和 .remove() 功能的模型中创建 MongooseArray/Collection

node.js - 如何编写 Express 路由器来排除路径

javascript - 模块化模块?需要父模块中的部分模块

node.js - Mongoose 查询 where

css -> * :first-child and > :first-child? 之间是否存在功能差异

html - 为什么 bootstrap 允许我使用 col-xs-13 而不是 col-xs-12?

jquery - 使用 jQuery 将链接项连接到内容 div id

javascript - 无法让我的脚本不断点击按钮

javascript - 如何使用 Node.js 获取 HTTP 请求中跟随的 javascript 名称?