在.html文件中将github repo中的.css文件引用为样式表 [英] Referencing a .css file in github repo as stylesheet in a .html file

查看:114
本文介绍了在.html文件中将github repo中的.css文件引用为样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在github上有一个.css文件的仓库。有什么办法让github以我可以在网页上使用这个文件的方式来提供这个文件吗?换句话说,我希望能够直接在github上引用此源文件,从本地计算机或活动域上的HTML文件引用。例如:

 < link rel =stylesheet
type =text / css
href =http://github.com/foouser/barproject/master/xenu-is-my-lover.css
/>

我试过包括< link> 转换为原始源文件( http://raw.github.com ... ),但github提供它的 Content-Type 为 text / plain ,因此,Chrome和FF不会将其内容作为CSS样式添加到页面中,文件的数据将被丢弃并且在浏览器的调试器中显示警告。 解决方案

GitHub回购站不是虚拟主机,你应该推这些东西直到专门设计用于提供文件的服务,如pages.github.com。


I've got a repository on github with a .css file in it. Is there any way to have github serve this file in a way that I can consume it in a web page?

In other words, I'd like to be able to reference this source file at github directly, from an HTML file on my local computer or a live domain. Something like:

<link rel="stylesheet"
      type="text/css"
      href="http://github.com/foouser/barproject/master/xenu-is-my-lover.css"
/>

I've tried including a<link> to the "raw" source file (http://raw.github.com...), but github serves its Content-Type as text/plain, and consequently, Chrome and FF are not adding its content as CSS styles to the page—the file's data is being discarded and a warning is shown in the debugger consoles of the browsers.

解决方案

GitHub repos aren't web hosting, you should push that stuff up to a service specifically designed to serve files, like pages.github.com.

这篇关于在.html文件中将github repo中的.css文件引用为样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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