如何在github托管站点中将CSS链接到HTML [英] How to link my CSS to my HTML in a github hosted site

查看:75
本文介绍了如何在github托管站点中将CSS链接到HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我试图托管Github页面的网站无法读取链接到它的CSS。

My problem is that my website that I'm attempting to host with Github pages will not read the CSS that I have linked to it.

我的HTML看起来像

<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="https://github.com/legoman8304/legoman8304.github.io/blob/master/style.css">
<html>
    <body>
        <h1>Hello World</h1>
        <p>I'm under construction!</p>
        <h6>Copyright MIT Licence 2018</h6>
    </body>
</html>

我的CSS看起来像这样:

My CSS looks like this:

body {
  background-color: lightblue;
}

h6 {
  color: navy;
  margin-left: 20px;
}

链接存储库: legoman8304.github.io

我猜我将CSS链接错误是因为我在网站本身上使用inspect元素,它确实显示 style.css ,但在打开时为空。有帮助吗?

I'm guessing I linked the CSS wrong because when I using inspect element on the site itself it does show style.css but when opened it's empty. Any help?

推荐答案

您需要将HTML链接到呈现为 style.css的github页面。

You need to link your HTML to the github page rendered style.css and not the file itself in the repo.

更改此内容:

<link rel="stylesheet" type="text/css" href="https://github.com/legoman8304/legoman8304.github.io/blob/master/style.css">

到此:

<link rel="stylesheet" type="text/css" href="https://legoman8304.github.io/style.css">

并将样式表引用移至< head> 标签。

And move that stylesheet reference inside your <head> tag.

这篇关于如何在github托管站点中将CSS链接到HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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