CSS在GitHub页面上显示的问题

huangapple go评论45阅读模式
英文:

CSS display issues with github pages

问题

在GitHub Pages上显示我的CSS遇到了问题。在默认浏览器中运行时一切正常(如图所示),但当我发布到页面时,它无法加载CSS。我尝试过更改href标签,但不确定在这一点上我做错了什么,经过几次尝试更改链接后。

仓库链接:https://github.com/trentstanley92/02ProfessionalPortfolio
页面链接:https://trentstanley92.github.io/02ProfessionalPortfolio/

默认浏览器中的CSS加载

我尝试过几次将href链接更改为"02ProfessionalPortfolio/Assets/styles.css"。最终,上面链接的那一行是我最后的尝试,起初是从"link rel="stylesheet" href="=./Assets/styles.css""开始的。我期望第二行能够自行加载CSS,但当它没有成功时,我尝试了大小写和在开头添加"./",当这些都不起作用时,我最终尝试了第一个和最后一个方式,但也没有成功。

英文:

Having trouble displaying my css on github pages. Everything works when ran in default browser (as seen in image) however when I published to pages it fails to load with the css. I have tried changing the href tag but not sure what I'm doing wrong at this point after a couple attempts at changing around the link.

Link to Repo: https://github.com/trentstanley92/02ProfessionalPortfolio
Link to Pages: https://trentstanley92.github.io/02ProfessionalPortfolio/

Default browser css loading

I have tried changing the href link to 02ProfessionalPortfolio/Assets/styles.css tag a couple times. Ultimately the one linked above is my final attempt after starting at link rel="stylesheet" href="=./Assets/styles.css". I expected the second line to pull up the css on its own, however after it didnt I messed around with the capitalization and the ./ at the beginning and when those did not work I resulted to the first and final attempt, which did not work either.

答案1

得分: 0

因为您已经在02ProfessionalPortfolio中,您可以将<link>元素中的href更改为"Assets/styles.css"。

英文:

Because you are already in 02ProfessionalPortfolio, you can change the href in the <link> element to "Assets/styles.css".

答案2

得分: 0

Use your web browser's Developer tools.

Your page is trying to load this:
https://trentstanley92.github.io/02ProfessionalPortfolio/02ProfessionalPortfolio/Assets/styles.css

But the file lives here:
https://trentstanley92.github.io/02ProfessionalPortfolio/Assets/styles.css

Your index.html is already at 02ProfessionalPortfolio, so you just need to write it as follows to hit the relative address:

<link rel="stylesheet" href="Assets/styles.css" />
英文:

Use your web browser's Developer tools.

Your page is trying to load this:
https://trentstanley92.github.io/02ProfessionalPortfolio/02ProfessionalPortfolio/Assets/styles.css

But the file lives here:
https://trentstanley92.github.io/02ProfessionalPortfolio/Assets/styles.css

Your index.html is already at 02ProfessionalPortfolio, so you just need to write it as follows to hit the relative address:

&lt;link rel=&quot;stylesheet&quot; href=&quot;Assets/styles.css&quot; /&gt;

huangapple
  • 本文由 发表于 2023年6月5日 06:14:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76402610.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定