CSS 在服务器中不起作用,但在本地机器上运行良好 [英] CSS is not working in the server but its working well in the local machine

查看:55
本文介绍了CSS 在服务器中不起作用,但在本地机器上运行良好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在服务器中上传静态网站并成功上传,但仅显示 HTML,未显示 CSS.但是当我在本地计算机上运行它时,它运行良好.国王

I am trying to upload a static website in the server and uploaded it successfully but only HTML is showing, CSS is not showing. but when I run it on my local computer it's working perfectly. king

推荐答案

你只需要更改 Style.cssmedia.css 的链接,因为它是本地的链接.

You just have to change the link of Style.css and media.css because it's a local link.

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

Imagine your files are stored in Resources folder, then you should change this:

<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 链接也存在同样的问题.看看这一行:

and there is a same problem with your scripts.js link. look at this line:

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

它应该类似地更改为:

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

它也指的是本地目录.

这篇关于CSS 在服务器中不起作用,但在本地机器上运行良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆