Why won't my CSS work on GitHub Pages?

拜拜、爱过 提交于 2020-01-06 02:28:10

问题


I'm making a web game called Sweet Shoppe, and I'm using GitHub Pages with it. The only problem is, the CSS won't work on GitHub Pages.

I've tried putting the CSS file in the main repo (and in a folder) and importing it through the HTML, but when I go to my page URL (which is set to mreikono.github.io/Sweet-Shoppe) the CSS that I have in the file (which adds a background of gray stripes to the body) fails to show up.

Mainly I want to know the following: What is the correct way to import some CSS into GitHub Pages?


回答1:


Looks like bootstrap is overriding your background color on line 896.

body {
  font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.42857143;
  color: #555555;
  background-color: #ffffff;
}

Try loading your stylesheet after bootstrap so that your styles are prioritized.

<head>
    <!-- Extra code files -->

    <!-- External files -->
    <link rel="stylesheet" href="http://bootswatch.com/lumen/bootstrap.css">
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
    <script src="http://code.jquery.com/jquery-git2.js"></script>

    <!-- CSS -->
    <link href="styles/style.css" rel="stylesheet" type="text/css">

    <!-- Misc attributes -->
    <meta charset="utf-8">
    <title>Sweet Shoppe</title>
</head>

https://developer.mozilla.org/en-US/docs/Web/CSS/Cascade



来源:https://stackoverflow.com/questions/24792958/why-wont-my-css-work-on-github-pages

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