【问题标题】:Why is CSS3 PIE not working on sub pages when using absolute path in the CSS file?为什么在 CSS 文件中使用绝对路径时 CSS3 PIE 不能在子页面上工作?
【发布时间】:2012-05-18 21:40:50
【问题描述】:

我有以下课程:

a.greenbutton, input.greenbutton  {
    /*background: url("../image/button.png") repeat-x scroll left top transparent;*/
    behavior: url("/css3pie/PIE.php");
    -webkit-border-radius: 7px;
    -moz-border-radius: 7px;
    border-radius: 7px 7px 7px 7px; 
    cursor: pointer;
    display: inline-block;
    line-height: 11px;
    padding: 6px 12px;
    text-decoration: none;
    background-color: green;
    color: white;
    position:relative;
    z-index: 0;     
}

PIE.php 文件位于/root/css3pie/

你可以看这里:

http://trashtalk.dk/

看看区别:

http://trashtalk.dk/Apple/iPhone

您甚至可以从以下位置下载文件:

http://trashtalk.dk/css3pie/PIE.php

我做错了什么?

【问题讨论】:

    标签: html css css3pie


    【解决方案1】:

    您使用的不是绝对路径,而是相对路径。要回答您的问题,我需要知道您的 css 文件位于何处(相对于您的根文件夹)。

    因为...如果它是 root/styles/ 或其他什么,那么您的 pie 规则需要在 /csspie 内容之前添加两个点“..”。

    换句话说,而不是:

    behavior: url("/css3pie/PIE.php");
    

    你需要:

    behavior: url("../css3pie/PIE.php");
    

    但这只是猜测,我需要先知道你的 css 文件/文件夹在哪里。

    好的,参考这个页面:

    http://css3pie.com/documentation/known-issues/

    行为网址

    IE 解释行为属性相对于源的 URL HTML 文档,而不是像其他所有文件一样相对于 CSS 文件 CSS 属性。这使得调用 PIE 行为不方便, 因为 URL 必须是:

    来自域根的绝对——这使得 CSS 不容易移动 在目录之间——或者,相对于 HTML 文档——这使得 CSS 不容易在不同的 HTML 文件之间重用。网址在 PIE 解释的 CSS 属性

    PIE 不解析 CSS 样式表(这样做是不可接受的 慢);它让 IE 处理解析、选择器查询、级联、 等等,然后简单地询问它得到的属性值。这 意味着当 PIE 获得一个属性值时,它不知道 该值源自的上下文。

    因此,对于包含 URL 值的属性(例如 border-image 或 -pie-background),PIE 无法解析这些 URL 相对于它们出现的 CSS 文件。它解决了他们 而是相对于 JavaScript 执行上下文,即 源 HTML 文档的位置。

    干杯
    G

    更新:

    确保您有条不紊地尝试了所有这些:

    1. 行为:url("../css3pie/PIE.php");
    2. 行为:url("/../css3pie/PIE.php");
    3. 行为:url("http://trashtalk.dk/css3pie/PIE.php");

    UHMMM...css 中的 css3 pie 规则在哪里?我看不到它,你知道,像 -pie-background 之类的东西。

    【讨论】:

    • 嗨,样式表位于:/public_html/catalog/view/theme/vasco/stylesheet 其中 public_html 是根文件夹。安德css3pie文件夹位于/public_html/css3pie/
    • 我尝试将 css3pie 文件夹与样式表放在同一个文件夹中,但我也没有工作
    • 我加了链接和解释,见我上面的原帖
    • 感谢您的回答。我的问题仍然没有解决。绝对路径应该是什么样的?目录在我上面的 cmets 中
    • 试试这个:行为:url("css3pie/PIE.php");
    猜你喜欢
    • 2018-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-17
    • 2011-09-23
    • 1970-01-01
    • 2014-12-09
    • 1970-01-01
    相关资源
    最近更新 更多