CSS文件路径问题 [英] CSS file pathing problem
问题描述
在我最喜欢的编辑器(此刻为TextPad)中设计HTML模板时,可以通过按F11或相应的工具栏按钮在浏览器中查看代码.我在一个单独的文件中有通用的CSS规则,因此我的HTML包含以下代码:
When designing a HTML template in my favorite editor (TextPad at the moment) I can view my code in a browser by pressing F11 or the appropriate toolbar button. I have my common css rules in a separate file so my HTML contains the code:
<link rel="stylesheet" href="commoncss.css" type="text/css">
当.css文件与.html文件位于同一文件夹中时,或者如果我在href属性中完全使用.css文件的路径,则此方法有效. ///c:/mycssfolder/commoncss.css
This works when the .css file is in the same folder as the .html file, or if I fully path the .css file in the href property, eg. ///c:/mycssfolder/commoncss.css
但是,在实时"情况下,我希望.css文件驻留在公共文件夹中,该文件夹可以从多个.html文件(例如,css文件夹位于href ='css/commoncss.css'中访问)是在网络服务器级别配置的.)
However, in a 'live' situation I want the .css file to reside in a common folder which is accessible from a number of .html files (eg. href='css/commoncss.css', where the css folder is configured at web-server level).
如何在不将css文件复制到所有.html文件夹(以及随之而来的所有维护难题)的情况下实现这种设计与实时困境?
How can I achieve this design vs. live dilemma without copying css file to all .html folders (and all the maintenance headaches that comes with it)?
我正在将Python 3.1与Jinja2配合使用,但是我想这个问题适用于所有语言和模板引擎.
I am using Python 3.1 with Jinja2, but I guess this problem is applicable across any language and template-engine.
任何帮助将不胜感激.
艾伦
推荐答案
<link rel='stylesheet' href='../css/stylesheet.css'>
这将向下移动一个级别,然后向上移动到/CSS/.
This will move down a level, then up a level to /CSS/.
这篇关于CSS文件路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!