【问题标题】:Base tag not working correctly基本标签无法正常工作
【发布时间】:2014-10-31 14:55:59
【问题描述】:

我在所有页面的顶部都有这段代码:

<base href="http://example.com/dev/">

在这个页面 (http://example.com/dev/index.php/foo/bar/) 我有这个代码:

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

但是我的浏览器一直在尝试加载:

http://example.com/dev/index.php/foo/style/common.css

什么时候应该:

http://example.com/dev/style/common.css

**更新**

<html>
<head>
        <base href="http://example.com/dev/" />
        <link rel="stylesheet" type="text/css" href="/style/video.css" />
        <link rel="stylesheet" type="text/css" href="/style/common.css" />

我是不是做错了什么?

彼得

【问题讨论】:

  • style/ 是一个相对 URL。尝试改用/style/common.css
  • &lt;base&gt; 必须位于具有href 属性的任何内容之前。确保&lt;base&gt; 是第一个。
  • @briansol 相对 URL 与基本元素一起使用。
  • 头部最顶部的基本网址
  • 试试&lt;base href="http://example.com/dev/index.html"&gt; 或 index.php。我认为这可能与您的 .htaccess 文件或某种 apache 重写有关。

标签: html hyperlink base


【解决方案1】:

我遇到了类似的问题。当页面通过 cgi 馈送时出现问题。这对我不起作用:

<base href="http://example.com/dev/">

但是,以下是:

<base href="/dev/">

【讨论】:

  • 出于某种原因,斜杠非常重要。非常感谢。
猜你喜欢
  • 1970-01-01
  • 2014-05-14
  • 1970-01-01
  • 1970-01-01
  • 2015-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-21
相关资源
最近更新 更多