首页 > 解决方案 > 如何将图像添加到 github 网站上的导航栏

问题描述

我正在制作一个 GitHub 网站,并希望将网站徽标添加为背景图片。目前代码是

body{
    <!--some other styling-->
    background-image: url(/geekoicon.png)
}

我已将图像文件上传到 Github,但它不在任何文件夹中,但是如果我访问我的网站,则什么都没有显示。当我尝试将图像放入文件夹并将新路径放入一个替换不存在图像的小图标时,弹出。如果有帮助,这里是 Github 项目页面https://github.com/Geeko/geeko.github.io

标签: htmlcssgithub

解决方案


由于图像位于您的 CSS 的位置,因此https://raw.githubusercontent.com/Geeko/geeko.github.io/master/geekoIcon.png您的 CSS 将如下所示:

body{
    background-image: url(https://raw.githubusercontent.com/Geeko/geeko.github.io/master/geekoIcon.png)
}

请注意,Github 网站的工作方式您也可以使用较短的 URL 来引用它https://geeko.github.io/geekoIcon.png


推荐阅读