1. 程式人生 > >Github網站css加載不出來的處理方法(轉,親測有效)

Github網站css加載不出來的處理方法(轉,親測有效)

github 沒有 tro 谷歌 use window mil end spa

轉載鏈接:https://blog.csdn.net/qq_36589706/article/details/80573008
因為工作需求,自己會經常使用到github,但是突然有一天打開github時,發現css樣式全沒了,如下圖,網速正常的時候也是這樣,怎麽辦呢,趁著今天周六,閑下來了,就找找博客,終於解決了,記錄一下~

場景重現:

技術分享圖片

網站響應緩慢,排版錯誤,圖片加載不出。

技術分享圖片

以谷歌瀏覽器為例,F12打開開發者選項,可以看到如下報錯信息:

技術分享圖片

可以看出,是Github需要在線加載的資源(css,js)文件未能成功加載

解決辦法:
為了提高速度,可以使用HOSTS加速對Github網站加載的資源網站域名解析。

具體做法:

修改 C:\Windows\System32\drivers\etc 中的hosts文件(PS:若沒有修改權限,可以鼠標右鍵,屬性,安全,修改權限。或者將hosts文件復制到桌面,修改之後,復制到原文件夾),將下面一段話添加到hosts文件中:

 # GitHub Start 
192.30.253.112 github.com 
192.30.253.119 gist.github.com 
151.101.100.133 assets-cdn.github.com 
151.101.100.133 raw.githubusercontent.com 
151.101.100.133 gist.githubusercontent.com 
151.101.100.133 cloud.githubusercontent.com 
151.101.100.133 camo.githubusercontent.com 
151.101.100.133 avatars0.githubusercontent.com 
151.101.100.133 avatars1.githubusercontent.com 
151.101.100.133 avatars2.githubusercontent.com 
151.101.100.133 avatars3.githubusercontent.com 
151.101.100.133 avatars4.githubusercontent.com 
151.101.100.133 avatars5.githubusercontent.com 
151.101.100.133 avatars6.githubusercontent.com 
151.101.100.133 avatars7.githubusercontent.com 
151.101.100.133 avatars8.githubusercontent.com
 # GitHub End

  

保存hosts文件,重新打開Github網站,此時網站的訪問應該可以恢復正常。

如果沒有立即恢復正常,需要刷新DNS緩存,告訴電腦我的hosts文件已經修改。Windows下刷新DNS緩存的方法:進入命令行,輸入命令:ipconfig /flushdns

技術分享圖片

Github網站css加載不出來的處理方法(轉,親測有效)