css not working on github pages

∥☆過路亽.° 提交于 2021-01-21 07:46:47

问题


I can't get my CSS to show on the site. I really can't figure out what I'm doing wrong here, I'm very new to all of this so I'm sure there's something I just can't see.

here is the live site https://rusne118.github.io/mile-stone-one/4

here is my repo https://github.com/rusne118/mile-stone-one

here is my css in my html

here is my files on cloud9


回答1:


Remember that GitHub pages are scoped with repo names.

You are including your CSS with

<link rel="stylesheet" href="/css/style.css">

This resolves to https://rusne118.github.io/css/style.css

but you want https://rusne118.github.io/mile-stone-one/css/style.css

Simply change link tag to

<link rel="stylesheet" href="/mile-stone-one/css/style.css">



回答2:


Adding type="text/css" to <link rel="stylesheet" href="style.css"> worked for me.

So finally it looked like <link rel="stylesheet" type="text/css" href="style.css">

In this case , the HTML file and the CSS file are located in the same folder.




回答3:


I had this problem and instead of doing:

<link rel="stylesheet" href="/css/style.css" />

I did:

<link rel="stylesheet" href="css/style.css" />

(without the first '/') And it worked fine.



来源:https://stackoverflow.com/questions/52003005/css-not-working-on-github-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!