我的网站由两页组成,加上我自己的 style.css,可以在我的本地完美运行。但是当我将它通过 FTP 传输到我的托管服务的服务器上时,index.html 无法从我的 style.css 中读取。我已经检查了路径。我检查了声明的顺序。我在本地维护了相同的文件结构和相同的 CSS 声明顺序(全局到本地),并且工作正常。有人有什么建议吗?
这是头部部分的样子:
我必须为文档中使用的脚本声明 CSS 样式。因为它不会读取我的 style.css,所以我做了一个内部声明。
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!--Google Font: Source Code Pro-->
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet">
<!-- Font Awesome CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Fancybox CSS -->
<link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox.min.css">
<!-- My CSS -->
<link rel="stylesheet" type="text/css" href="css/style.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- Fancybox jQuery -->
<script src="fancybox/jquery.fancybox.min.js"></script>
<style type="text/css">
.menuActive {
background-color: #ffffff;
}
</style>
</head>
我在服务器上的文件结构的相关部分如下(尝试包括屏幕截图,但显然我还不能在 Stackoverflow 上这样做):
文件夹和文件: CSS 花式盒子 文件 图片 wp_admin wp-内容 wp-包含 .ftp配额 .htaccess 默认.htm index.html
img 文件夹与 css 文件夹处于同一级别,并且图像正在正确加载。
最佳答案
这可能是因为在您的服务器上您正在使用 https://
将您的样式链接更改为类似 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
的内容并删除 http 部分
关于html - FTP 到服务器后,index.html 无法从 CSS 读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44189771/