[英]CSS not loading for GitHub pages
I have a site published with GitHub pages:我有一个用 GitHub 页面发布的网站:
https://safelyswift.github.io/Swizzle/ https://safelyswift.github.io/Swizzle/
I want to use docs/css/style.css
in my index.html
file.我想在我的
index.html
文件中使用docs/css/style.css
。 I have tried using the full url, GitHub raw url, and shortened url but none of them work.我曾尝试使用完整 url、GitHub 原始 url 和缩短的 url,但它们都不起作用。
ie: I have tried many variations on this line:即:我在这条线上尝试了很多变体:
<link rel="stylesheet" href="https://github.com/SafelySwift/Swizzle/blob/master/docs/css/style.css">
<link rel="stylesheet" href="/Swizzle/docs/css/style.css">
<link rel="stylesheet" href="https://raw.githubusercontent.com/SafelySwift/Swizzle/master/docs/css/style.css">
but none work.但没有工作。
Getting error:获取错误:
Did not parse stylesheet at 'https://github.com/SafelySwift/Swizzle/blob/master/docs/css/style.css' because non CSS MIME types are not allowed in strict mode.
in Safari debug console.在 Safari 调试控制台中。
尝试: <link rel="stylesheet" href="css/style.css">
You should link to css/style.css
, which is short of https://safelyswift.github.io/Swizzle/css/style.css because the root directory of your GitHub Page is /docs
.你应该链接到
css/style.css
,它没有https://safelyswift.github.io/Swizzle/css/style.css因为你的 GitHub Page 的根目录是/docs
。
The reason " https://github.com/SafelySwift/Swizzle/blob/master/docs/css/style.css " not work is because this link actually goes to the GitHub code preview page. “ https://github.com/SafelySwift/Swizzle/blob/master/docs/css/style.css ”不起作用的原因是因为此链接实际上转到了 GitHub 代码预览页面。 It's not a valid CSS file but an HTML page with lots of GitHub functions(preview, commit log, history, etc.) But " https://safelyswift.github.io/Swizzle/css/style.css " is served by GitHub Page, so this link contains only pure CSS file which is valid.
它不是一个有效的 CSS 文件,而是一个包含许多 GitHub 功能(预览、提交日志、历史记录等)的 HTML 页面但是“ https://safelyswift.github.io/Swizzle/css/style.css ”由 GitHub 提供页面,因此此链接仅包含有效的纯 CSS 文件。
To see the difference between these files.要查看这些文件之间的区别。 Just navigate these link with your browser, and right-click your page to see the source code.
只需使用浏览器导航这些链接,然后右键单击您的页面即可查看源代码。 You can see what your browser sees there.
您可以看到浏览器在那里看到的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.