繁体   English   中英

无法加载我的CSS和JS文件

[英]Having trouble getting my css and js file to load in

因此,这里的问题是:我开始在没有先验知识的情况下对html进行编码,因此很遗憾,我没有创建.css或.js文件。 相当不错的是,在我正在工作的网站上,我试图将所有样式信息和js代码放入各自的文件中,同时删除了原始html中的内容。 经过大量审查,我找不到问题。 它们都应该正确链接,因为所有内容都位于同一目录中,并且我放置了一些js代码来证明未加载“外部”文件中的jquery文件。

这是我的js文件,css和html的标题。

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
 hr { margin: 1px; } body { background: url("Brown Background 2 adjusted.jpg") no-repeat ; background-attachment: fixed; background-position: ; background-size: cover; } html{ margin:0; padding:0; } body,h1, p .mainfont{ font-family: "Helvetica Neue", "Segoe UI", Segoe, Helvetica, Arial, "Lucida Grande", sans-serif; font-weight: normal; margin: 0px; padding: 0px; text-align: center; } @font-face { font-family: 'myFirstFont'; src: url('melmacracked.woff') format('woff'); } #titleheader { color:#6b4527; font-size: 48px; font-family: 'myFirstFont'; } img{ width: 50%; } h1 { font-size: 48px; font-weight: 300; margin: 0 0 0px 0; } .lead { font-size: 21px; font-weight: 200; margin-bottom: 0px; } p { margin: 0 0 0px; } .margin{ margin:30px; } 
 <!DOCTYPE html> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <link rel="stylesheet" href="fishook-theme.css" type="text/css" /> <script type="text/javascript" src="external.js"></script> <script>if (typeof jQuery != 'undefined') { alert("jQuery library is loaded!"); }else{ alert("jQuery library is not found!"); }</script> </head> 

仅供参考,我已经阅读了许多其他帖子,其中包含同样的模糊问题,但没有解决该问题的解决方案。 提前致谢。

所以,如果我理解正确,第一个代码片段在您的js文件中?

好吧,这就是问题所在。 它应该在您的html文件中。 js文件不了解html代码段。 它不知道该怎么办。

 <!DOCTYPE html> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <link rel="stylesheet" href="fishook-theme.css" type="text/css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script> <script>if (typeof jQuery != 'undefined') { alert("jQuery library is loaded!"); } else { alert("jQuery library is not found!"); } </script> </head> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM