在硬盘上同一目录中的HTML文档上链接CSS文件(Windows) [英] Linking CSS File on a HTML Document In Same Directory On my Hard Disk (Windows)

查看:84
本文介绍了在硬盘上同一目录中的HTML文档上链接CSS文件(Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Windows (7)尝试创建一个脱机html页面,该页面应链接到位于同一目录中的单独CSS文件。我尝试使用

I am using Windows (7) trying to create an offline html page that should link to a separate CSS file located in same directory. I tried to use

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

但没有运气。

还希望在style.css中导入另一个名为styles2.css的css文件。尚未检查,但将 @import style2.css; 放在style.css上可能无法正常工作。我可以使用像 C:\Users\ELITEBOOK\Desktop\offline\style.css 这样的绝对链接,但是如果我将文件夹移到任何地方都无法使用其他来自桌面。有什么帮助吗?我的意思是,是否有调用/添加文件夹链接的代码?

And I also want to import another css file named styles2.css within style.css. Didn't check yet but putting @import "style2.css"; on style.css may be not work as well. I can use absolute links like C:\Users\ELITEBOOK\Desktop\offline\style.css but it won't work if I move the folder anywhere else from Desktop. Any help? I mean, any code that calls/adds the link of the folder?

推荐答案

使用< link rel = stylesheet type = text / css href = ./ styles.css /> 代替。注意: href = / styles.css 更改为 href = ./ styles.css 您脚本的当前目录。

Use <link rel="stylesheet" type="text/css" href="./styles.css" /> instead. Note: href="/styles.css" changed to href="./styles.css", which is current directory of your script.

这篇关于在硬盘上同一目录中的HTML文档上链接CSS文件(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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