CSS 在服务器上不工作,但在本地机器上工作正常

CSS is not working in the server but its working well in the local machine

我正在尝试在服务器中上传一个静态网站并成功上传,但只有 HTML 显示,CSS 没有显示。但是当我 运行 它在我的本地计算机上时,它工作得很好。 国王

head 中样式表的 link wrong/doesn 不起作用(找不到文件):

<link rel="stylesheet" type="text/css" href="Resources/css/Style.css">

显然是本地link,但你需要让它适应server/domain环境

您的 css 文件的名称是 style.css,但链接为 Style.css

你只需要改变 Style.cssmedia.css 的 link 因为它是本地 link.

假设您的文件存储在 Resources 文件夹中,那么您应该更改为:

<link rel="stylesheet" type="text/css" href="Resources/css/Style.css">
<link rel="stylesheet" type="text/css" href="Resources/css/media.css">

对此:

<link rel="stylesheet" type="text/css" href="/Resources/css/Style.css">
<link rel="stylesheet" type="text/css" href="/Resources/css/media.css">

你的 scripts.js link 也有同样的问题。看看这一行:

<script src="resources/js/script.js"></script>

同样应该改成这样:

<script src="/resources/js/script.js"></script>

也是指本地目录。