在本地主机时无法加载外部CSS [英] Can't load external css when in localhost
问题描述
我正在使用arduino,node.js和socket.io进行项目.我在本地主机上运行它,但是我的外部样式表无法加载.
错误似乎表明它无法从此路径获取我的CSS
这是我在css文件夹中的main.css文件
我的main.css文件位于css文件夹中,我正在使用interface.html文件
尝试以下方法:
< link rel ="stylesheet" type ="text/css" href ="./css/main.css">
注意href前面的 ./
否则请包含完整路径名:
< link rel ="stylesheet" type ="text/css" href ="http://localhost:1337/css/main.css">
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屋!