【问题标题】:Php include head with a link to the css dont workphp包含带有指向css链接的头不起作用
【发布时间】:2016-11-14 03:45:18
【问题描述】:

我已经开始使用php了。并遇到了第一个问题,我无法摆脱。我希望我的index.php 带有此代码(在头部):

<head>
<?php
    require 'php/main/head.html';
?>
</head>

使用此代码访问我的head.html

<link href="../../style/style.css" rel="stylesheet" type="text/css" />
<link href="../../style/fonts.css" rel="stylesheet" type="text/css">
<link href="../../style/responsive.css" rel="stylesheet" type="text/css">
<link href="http://www.mike-kaufmann.de/global/current_year.css" rel="stylesheet" type="text.css">
<link href="../../img/favicon.ico" rel="shortcut icon" type="image/x-icon" />
// and more code..

第一个链接应该“通常”从style.css 获取信息,但它不需要任何东西。好像走错了路。

css 中的代码应该对index.php 中的元素做一些边距;但我之前说过,它什么都不做。

我现在的问题是:如何/我必须做什么才能访问我的 style.css

如果代码难以阅读,您可以下载并自行测试: Dropbox-link 或在我的Github Repo 上查看并在那里上传一些更改。

问题:我读到包含功能让用户每次都重新加载网站。意味着它不使用缓存。真的吗?如果是,我可以使用什么来获得良好的网络性能?

感谢所有回答。

问候迈克。 :)

【问题讨论】:

    标签: php html css require head


    【解决方案1】:

    我现在的问题是:如何/我必须做什么才能访问我的 样式.css;

    你做对了:

    <meta name="description" content="#"/>
    <meta name="keywords" content="#"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="copyright" content="Last Death" />
    <meta name="author" content="Mike Kaufmann"/>
    <meta charset="UTF-8"/>
    
    <link href="style/style.css" rel="stylesheet" type="text/css" />
    <link href="style/fonts.css" rel="stylesheet" type="text/css">
    <link href="style/responsive.css" rel="stylesheet" type="text/css">
    <link href="http://www.mike-kaufmann.de/global/current_year.css" rel="stylesheet" type="text.css">
    <link href="img/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    
    <meta property="og:image" content="http://www.site-check.cc/files/themen/zoom/vorschaubild.jpg"/> <!--Für Facebook links-->
    

    除了这个代码type="text.css"应该是type="text/css"

    我读过包含功能让用户加载网站 每一次。意味着它不使用缓存。真的吗?如果它 是,我可以使用什么来获得良好的网络性能?

    是的,它正在尝试。但不要对 3-5 次收录的表现感到压力。现代 php 框架通常包含更多的内容。

    但如果您仍想减少 includes 负载影响,请将 footerheadheader 放在一个 layout.php 上,然后让 layout.php 包含动态 php 部分。

    【讨论】:

    • 嗨,我已经试过了。它不起作用,这是我的问题......我不知道为什么。
    【解决方案2】:

    根据您的GitHub repostyle 目录与您的index.php 文件处于同一层次结构,因此无需使用../../../ 表示从脚本所在的当前目录升级。从所有资产中删除 ../../,它们将开始正常工作。

    【讨论】:

      【解决方案3】:

      ../ 本质上表示在目录树中向上移动一个目录。查看您的 github 存储库,您需要做的就是更改您的

      &lt;link href="../../style/style.css" rel="stylesheet" type="text/css" /&gt;&lt;link href="style/style.css" rel="stylesheet" type="text/css" /&gt;

      【讨论】:

        【解决方案4】:

        对不起,是我的错。我没有启动我的服务器 -.- 我是个白痴。

        【讨论】:

          猜你喜欢
          • 2011-03-30
          • 2013-10-30
          • 1970-01-01
          • 1970-01-01
          • 2017-06-25
          • 1970-01-01
          • 1970-01-01
          • 2012-05-28
          • 1970-01-01
          相关资源
          最近更新 更多