代码之家  ›  专栏  ›  技术社区  ›  Charles Roper

What does @-moz-document url-prefix() do?

css
  •  75
  • Charles Roper  · 技术社区  · 16 年前

    在西蒙·科里森家 new Responsive Web Design 在CSS中,有以下几种声明:

    @-moz-document url-prefix() {
      .fl { float:left; margin:12px 4px 0 0; padding:0; font-size:65px;  line-height:62%;  color:#ba1820; }
      .fs { float:left; margin:12px 4px 10px 0; padding:0; font-size:65px; line-height:62%; color:#ba1820; }
    }
    

    这实际上是做什么的?我在google上搜索了@-moz文档url-prefix(),找到了在userchrome中使用它的引用,但没有找到标准的站点样式表。

    It usually has a URL passed in as an argument which then restricts the content of the declaration to that URL. However, on Colly's site, there is no argument being passed in. This would indicate that the declaration is operating on the current URL, or 任何 URL,不是吗?所以 我们在这里看到的是一种针对仅Mozilla浏览器的特定规则 ?

    3 回复  |  直到 8 年前
        1
  •  84
  •   Oded    11 年前

    任何以 @-moz- 是特定于Gecko引擎的规则,而不是标准规则。也就是说,它是特定于Mozilla的扩展。

    这个 url-prefix rule applies the contained style rules to any page whose URL starts with it. When used with no URL argument like @-moz-document url-prefix() 适用于 所有 页。That's effectively a CSS hack 只针对壁虎(Mozilla Firefox)。所有其他浏览器都将忽略样式。

    here for a list of other Mozilla-specific extensions.

        2
  •  16
  •   Bella    16 年前

    https://developer.mozilla.org/en/CSS/@-moz-document

           @-moz-document url(http://www.w3.org/),
                       url-prefix(http://www.w3.org/Style/),
                       domain(mozilla.org)
        {
          /* CSS rules here apply to:
             + The page "http://www.w3.org/".
             + Any page whose URL begins with "http://www.w3.org/Style/"
             + Any page whose URL's host is "mozilla.org" or ends with
               ".mozilla.org"
           */
    
          /* make the above-mentioned pages really ugly */
          body { color: purple; background: yellow; }
    }
    
        3
  •  0
  •   Adam    8 年前

    从Firefox 59开始,您应该只使用:

    @document url("https://www.example.com/")

    Web内容已停止对此属性的-moz前缀版本的支持,原因是出现了以下错误:

    https://bugzilla.mozilla.org/show_bug.cgi?id=1035091