【问题标题】:Including css from other folder包括来自其他文件夹的 css
【发布时间】:2017-03-20 02:33:32
【问题描述】:

我想知道是否有一种简单的常用方法可以从另一个文件夹中的 html/php 文件中包含一个文件夹中的 css 文件?

结构如下:

  • index.php
  • 关于
    • index.php
  • CSS
    • style.css

我想知道如何从隐藏在 about 目录中的 index.php 中获取 css 文件夹中 style.css 文件的正确路径。

【问题讨论】:

  • 您需要一个简单的方法吗?你尝试过的困难方式是什么?请在您的问题中分享代码。对于上一级使用“../”,所以从 index.ph 链接将是这样的 ../css/style.css
  • 通过带有项目名称的 $_SERVER['DOCUMENT_ROOT']。它并没有真正奏效,但我知道有一个非常简单的方法可以做到这一点。而“../”正是我要找的,但找不到。

标签: php html css include directory


【解决方案1】:

这是在about/index.php

<link rel="stylesheet" href="../css/style.css" />

.. 基本上说,“从这个脚本所在的位置上一层。”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-08
    相关资源
    最近更新 更多