Github не работает css

CSS не загружается для страниц GitHub

У меня есть сайт, опубликованный со страницами GitHub: https://safelyswift.github.io/Swizzle/ Я хочу использовать docs/css/style.css в моем файле index.html . Я попытался использовать полный URL-адрес, необработанный URL-адрес GitHub и сокращенный URL-адрес, но ни один из них не работает. то есть: я пробовал много вариантов в этой строке:

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. 

2 ответа

Вы должны сделать ссылку на css/style.css , который не хватает https://safelyswift.github.io/Swizzle/css/style.css, потому что корневой каталог вашей страницы GitHub — /docs .

Причина, по которой » https://github.com/SafelySwift/Swizzle/blob/master/docs/css/style.css » не работает, заключается в том, что эта ссылка фактически ведет на страницу предварительного просмотра кода GitHub. Это не действительный файл CSS, а HTML-страница с множеством функций GitHub (предварительный просмотр, журнал фиксации, история и т.д.), Но GitHub обслуживает https://safelyswift.github.io/Swizzle/css/style.css. Страница, поэтому эта ссылка содержит только чистый файл CSS, который является действительным.

Чтобы увидеть разницу между этими файлами. Просто перейдите по этой ссылке в браузере и щелкните правой кнопкой мыши на своей странице, чтобы увидеть исходный код. Вы можете увидеть, что там видит ваш браузер.

Читайте также:  Python создать класс динамически

Большой! Интересно, почему это исправило это? Это потому, что GitHub добавляет к нему https://github.com/SafelySwift/Swizzle/blob/master/docs/ ?

@NoobTW ответил на это довольно хорошо. Он основан на том, какой у вас корень или где все ваши файлы находятся в вашем хранилище. Если в хранилище нет папок, то путь — это filename . Если есть папка и файл в ней, то это folder/filename . Рад, что смог помочь.

Источник

Почему github.io не хочет видеть css

Вот таблица стилей:
https://github.com/LinuxCNC-rus-documentation/LinuxCNC-rus-documentation.gith.
Грузится она в html странице лежащей в папке common вот этой строкой

По идее она должна быть доступна как
https://linuxcnc-rus-documentation.github.io//asciidoc.css
но почему то github.io пишет что файл по этому линку не найден.
В чём может быть дело?

На количество слешей в урле всем насрать. А ТС скорее всего накосячил с относительными путями.

torvn77 , тут галочек нету на последних коммитах, это значит, что они не были перенесены на хостинг. Может какой-то лимит был превышен и при следующем пуше всё обновится.

Скопировал ссылку в браузер и убрал двойной слеш, всё равно не открывает.

Спасибо. Если не обновиться то буду выяснять в чём дело.

torvn77 ★★★★★ ( 10.09.17 12:10:30 MSK )
Последнее исправление: torvn77 10.09.17 12:11:13 MSK (всего исправлений: 1)

xaizek , правильно сказал.
Зайди в Settings, где настройка GitHub Pages. Там по идее должно быть написано из-за чего.
А вот ряд причин: https://help.github.com/articles/troubleshooting-github-pages-builds/

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

GitHub Community

CSS not being applied in pages :/ #22495

I am new to github. I’ve been following tutoials etc on how to set up pages. Now, i’m trying to move my codepen HTML and CSS over here. HTML is working, but CSS is not being applied.

I’m obviously doing something wrong. But I can’t figure it out.

Thank you in advance fo any pointers.

Beta Was this translation helpful? Give feedback.

70 You must be logged in to vote

Thanks for bringing up this topic, as this is a very common issue we see! First of all, it does appear that after making the change suggested by @SethClydesdale your CSS did start working, and https://noethix.github.io/trial/ looks great! Sometimes it can take a minute for updates to show up, or an old version is cached by your browser, and I suspect that’s what happened here.

It also looks like @MangbawiTawmbing’s issue has been resolved as well, as I see that https://mangbawitawmbing.github.io/ludo/dicee.html is correctly displaying its CSS.

For all those coming to this topic later with a similar issue, below are some common situations where we see CSS not working proper…

Replies: 20 comments · 10 replies

Looking at your page, it appears the issue is the “/” at the beginning of your stylesheet’s source. Change “/css/main.css” to “css/main.css” (on line 5 of index.html) and it should fix the issue you’re having.

For future reference, if the html file is in the same directory as another folder or file, you don’t need to include a slash at the beginning of the src or href attributes. Also, if you need to access files up one, two, or however many directories, you can use two periods as a substitute. (example below)

root —> resources —> stylesheet.css

root —> lessons —> lesson-1 —> exercise-1 —> index.html

For our html file to access the stylesheet we could provide the following.

Basically two “…” moves up a directory and since index.html was three directories down, we moved up three times until we were in the root thus able to access the resources folder. You can also reference the current directory with “./”.

If any questions, let us know.

Beta Was this translation helpful? Give feedback.

9 You must be logged in to vote

Beta Was this translation helpful? Give feedback.

Why my CSS is not working properly?
I have tried it through live server, Its alright but after committing and the server is live there is a design that I have uploader previously.

Beta Was this translation helpful? Give feedback.

thank you it was a big proplem for me

Beta Was this translation helpful? Give feedback.

Thank you @sethclydesdale for your detailed answer and the tips ! But it didn’t work either…

Beta Was this translation helpful? Give feedback.

5 You must be logged in to vote

CSS appears to be working when I look at https://noethix.github.io/trial. Do you see it as working now? Or can you describe what is not working for you?

Beta Was this translation helpful? Give feedback.

1 You must be logged in to vote

Thank you, that helped me so much; not only for CSS but also for IMAGE directories (I used to work with underline before its names, like: “_css or _image”).

So, I had to took them off and changed on HTML and CSS as well so it could work.

Beta Was this translation helpful? Give feedback.

4 You must be logged in to vote

Hello, I am facing the same issue. Did you happen to find a fix for it?

Thank you @sethclydesdale for your detailed answer and the tips ! But it didn’t work either…

Beta Was this translation helpful? Give feedback.

9 You must be logged in to vote

I tried few things which worked for me. I assume those are not major reasons; but still you can try

  1. Remove the css folder and keep your index file and css at same place, and remove the hierarchy in link attribute as href=“main.css”.
  2. Add in head tag

It worked then; I reshuffled the order to check if that is the reason; it is working since then for no absolute reason for shuffling the order.

And I am assuming each time you commit the change; in settings under GitHub Pages Section revisit the master brance in source option and then publish.

Beta Was this translation helpful? Give feedback.

4 You must be logged in to vote

thank you, it worked for me, i only had to add the type=»text/css»

Beta Was this translation helpful? Give feedback.

I tried few things which worked for me. I assume those are not major reasons; but still you can try

  1. Remove the css folder and keep your index file and css at same place, and remove the hierarchy in link attribute as href=“main.css”.
  2. Add in head tag

It worked then; I reshuffled the order to check if that is the reason; it is working since then for no absolute reason for shuffling the order.

And I am assuming each time you commit the change; in settings under GitHub Pages Section revisit the master brance in source option and then publish.

Beta Was this translation helpful? Give feedback.

3 You must be logged in to vote

Can you help me with mine?

Beta Was this translation helpful? Give feedback.

1 You must be logged in to vote

Thanks for bringing up this topic, as this is a very common issue we see! First of all, it does appear that after making the change suggested by @SethClydesdale your CSS did start working, and https://noethix.github.io/trial/ looks great! Sometimes it can take a minute for updates to show up, or an old version is cached by your browser, and I suspect that’s what happened here.

It also looks like @MangbawiTawmbing’s issue has been resolved as well, as I see that https://mangbawitawmbing.github.io/ludo/dicee.html is correctly displaying its CSS.

For all those coming to this topic later with a similar issue, below are some common situations where we see CSS not working properly, and how to fix it.

Check for these common issues:

Incorrect URL to the stylesheet

Sometimes people accidentally use a stylesheet URL/directory path for their local computer, e.g.

Solution:
Use a relative path to refer to your file, e.g. .

Incorrect path to the stylesheet

Sometimes people reference the stylesheet at the wrong place, e.g.

Solution:
Double check the path to the stylesheet.

Incorrect capitalization

People can also accidentally have capitalization that doesn’t match the filename. For example, the stylesheet is referenced like this:
.

However, the file is named styles.CSS . As a result, the stylesheet won’t be loaded since since GitHub Pages is case-sensitive.

Solution:
Double check to ensure all capitalization matches.

Better Solution:
Use all lowercase letters for all filenames and URLs.

Missing file or directory

Sometimes we find that the stylesheet or even entire css directory was never uploaded or pushed to the repository. This often happens when using the web interface to upload files.

Solution:
Ensure all files and directories have been pushed to the repository, so that the contents of the GitHub repository matches the contents of your local repository.

CSS stops working after adding custom domain

We often have people write in to tell us that their CSS was working fine until they added a custom domain to their repository. One way to prevent many of these types of issues is to use relative paths, but some site builders do use the full URL as a base path, so you may need to change a setting or two.

Solution:
Change React or Jekyll settings:

For Jekyll sites, edit _config.yml . If values are set for baseurl or url variables, we recommend deleting these lines entirely. This will allow GitHub Pages to detect and configure the ideal baseurl and url values in the background, automatically adjusting for changes to your site’s custom domain.

For React sites, edit package.json . Change the “homepage” setting to your custom domain. Ensure that this setting matches the exact domain specified in your repository’s CNAME file.

For example, if your CNAME file contains mydomain.com , your package.json file should contain:

If your CNAME file contains www.mydomain.com , your package.json file should contain:

“homepage”: “https://www.domain.com” 

Additional Resources

If you are here looking for a solution to your CSS issue, I hope we’ve been able to help with the information above! Here are some additional resources that may be helpful:

Explanation of absolute vs. relative paths:

What is a URL?

With Hypertext and HTTP, URL is one of the key concepts of the Web. It is the mechanism used by browsers to retrieve any published resource on the web.

Introduction to using cascading style sheets:

CSS: Cascading Style Sheets

Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in HTML

Instructions on deploying a React app to GitHub Pages:

Create React App · Set up a modern web app by running one command.

`npm run build` creates a `build` directory with a production build of your app. Set up your favorite HTTP server so that a visitor to your site is served `index.html`, and requests to static paths like `/static/js/main..js` are served with the.

Beta Was this translation helpful? Give feedback.

Источник

Оцените статью