在本地主机中时无法加载外部 css [英] Can't load external css when in localhost

查看:33
本文介绍了在本地主机中时无法加载外部 css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 arduino、node.js 和 socket.io 的项目.我在本地主机上运行它,但是我的外部样式表不会加载.

错误似乎是说它无法从这个路径获取我的 css

这是我在 css 文件夹中的 main.css 文件

我的 main.css 文件在 css 文件夹中,我正在处理 interface.html 文件

解决方案

试试这个:

注意href前面的./

否则包括完整路径名:

I'm working on a project using arduino, node.js and socket.io. I am running it in localhost, however my external stylesheet wont load.

The error seems to be saying it cant get my css from this path http://localhost:1337/css/main.css

However if i keep the css in a style tag in the html file it all works fine, is there a way to keep the css external so it doesnt clutter my html file?

Heres how im loading in my css

<link rel="stylesheet" type="text/css" href="css/main.css">

Here is how my file structure looks

Here is my main.css file inside the css folder

my main.css file is within the css folder, i am working off of the interface.html file

解决方案

Try this instead:

<link rel="stylesheet" type="text/css" href="./css/main.css">

notice the ./ in front of the href

otherwise include full path name:

<link rel="stylesheet" type="text/css" href="http://localhost:1337/css/main.css">

这篇关于在本地主机中时无法加载外部 css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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