CSS链接到硬盘上的文件? [英] CSS link to file on harddrive?

查看:75
本文介绍了CSS链接到硬盘上的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以链接到硬盘驱动器上的css文件(MAMP或类似的外部)?以下不适用于我:

 < link rel =stylesheettype =text / cssmedia = screenhref =C:\mystyles.css/> 

谢谢

解决方案尝试使用 file:/// 协议。

  href ='file:/// C:\mystyles.css'

如果那样做没有工作(你说它没有),那么我的猜测是,它不会工作,因为它被浏览器的安全功能所阻止。



这取决于你从哪里加载主HTML内容,但是如果主HTML是从互联网上加载的,那么我可以理解为什么浏览器可能会反对从客户机的本地文件系统加载CSS。



最后一件尝试:您可以尝试在您的机器上设置一个Web服务器,将mystyles.css文件放入Web文件夹,然后使用以下命令将其加载到页面中:

  href ='http://localhost/mystyles.css'

我无法提出其他建议,我不认为。


Is it possible to link to a css file on a hard drive (outside of MAMP or similar)? The following isn't working for me:

<link rel="stylesheet" type="text/css" media="screen" href="C:\mystyles.css" />

Thanks

解决方案

try using the file:/// protocol.

href='file:///C:\mystyles.css'

If that doesn't work (and you say it doesnt), then my guess is that it won't work at all due to it being prevented by security features in the browser.

It depends on where you are loading the main HTML content from, but if the main HTML is loaded from the internet then I can understand why the browser might object to loading the CSS from the client machine's local file system.

One final thing to try: You might try setting up a web server on your machine, putting the mystyles.css file into the web folder, and loading it into the page using:

href='http://localhost/mystyles.css'

I can't really suggest much else, I don't think.

这篇关于CSS链接到硬盘上的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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