如何将外部样式表链接到多个页面和文件夹? [英] How do I link external style sheet to multiple pages and folders?

查看:43
本文介绍了如何将外部样式表链接到多个页面和文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个非常大的网站,其中包含许多页面和文件夹.我有 1 个样式表.

im building a pretty large website that will have many pages and folders. I have 1 stylesheet.

如何将样式表添加到这些文件夹的所有"中?在我开始将页面放在单独的文件夹中之前,我没有遇到这个问题.现在每个页面都有自己的文件夹,除非它在 ​​SAME 文件夹中,否则它不再读取我的样式表

How do I add the style sheet to "ALL" of these folders? I didnt have this problem before I started to put the pages in SEPERATE folders. Now that each page has its own folder it no longer reads my stylesheet unless its in the SAME folder

例如,假设我有一个宠物文件夹、另一个汽车文件夹和另一个飞机文件夹.我必须将我的样式表放在 EACH 和所有这些文件夹中,以便我可以看到我的网站.我怎样才能做到这样我就不必在每个文件夹中都放置一个样式表?

Example, lets say I have a folder of pets, another of cars, and another of planes. I have to put my stylesheet in EACH and everyone of these folders so that I can see my site. How can I do it so that I do NOT have to put a stylesheet in each and every folder?

换句话说,我怎样才能让我的样式表与我的文件夹位于同一页面上,而无需将它们放在该文件夹中?我怎样才能让他们在不同的文件夹中进行通信?

In other words how can I get my stylesheets on the same page as my folders without having them in that folder? How can I get them to communicate while being in a different folder?

推荐答案

如果一个文件链接在当前目录之上(意味着你要链接的文件在链接文档所在的文件夹之外)你必须写像这样:

If a file is linked above the current directory (meaning the file you want to link is outside of the folder where the linked document is stored) you have to write it like this:

../file.html

如果它在当前目录之上并在不同的文件夹中,您可以像这样链接:

If it is above the current directory and inside a different folder, you link like this:

../diffFolder/file.html

如果它在当前目录的更深处(意味着它在当前目录的文件夹中),请这样做:

If it is deeper in the current directory (meaning it is within a folder of the current directory) do it like this:

deeperFolder/file.html

当然,另一种选择是创建一个 php 头文件并将其包含在您的其他页面中.这确实是重用内容的大型网站的方法.我现在正在一个小型网站上工作,但重用的每个部分都是它自己的单独文档,每当调用链接时,服务器端都需要该文档.因此,如果我对标题进行更改,它会影响每个页面.与页脚、侧边栏等相同.

The other option of course would be to create a php header document and require/include it in your other pages. It really is the way to go with big sites that reuse content. I am working on a smallish website right now, but every part that is reused is it's own individual document that is required server side whenever the link is called. So if I make a change to the header, it affects every page. Same with footer, sidebar, etc.

这个网站实际上在一个非常基本的层面上很好地解释了动态包含:http://inobscuro.com/tutorials/php-dynamic-includes-16/#

This website actually explains dynamic inclusion on a pretty basic level quite well: http://inobscuro.com/tutorials/php-dynamic-includes-16/#

这篇关于如何将外部样式表链接到多个页面和文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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