CSS url()函数的示例用法是什么?

前端之家收集整理的这篇文章主要介绍了CSS url()函数的示例用法是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
3.4. Resource Locators: the <url> type描述了< url-modifier>在

A URL is a pointer to a resource and is a functional notation@H_403_8@ denoted by <url>. The Syntax of a <url> is:

<url> = url( <string> <url-modifier>* )

In addition to the Syntax defined above,a can sometimes be@H_403_8@ written in other ways:

  • For legacy reasons,a <url> can be written without quotation marks around the URL itself. This Syntax is specially-parsed,and@H_403_8@ produces a <url-token> rather than a function syntactically.@H_403_8@ [07001]

  • Some CSS contexts,such as 07002,allow a <url> to be represented by a 07003 instead. This behaves identically to@H_403_8@ writing a url() function containing that string. Because these@H_403_8@ alternate ways of writing a <url> are not functional notations,they@H_403_8@ cannot accept any <url-modifier>s.

Note: The special parsing rules for the legacy quotation mark-less@H_403_8@ <url> Syntax means that parentheses,whitespace characters,single@H_403_8@ quotes (‘) and double quotes (“) appearing in a URL must be escaped@H_403_8@ with a backslash,e.g. url(open\(parens),url(close\)parens).@H_403_8@ Depending on the type of URL,it might also be possible to write these@H_403_8@ characters as URL-escapes (e.g. url(open%28parens) or@H_403_8@ url(close%29parens)) as described in[07004]. (If written as a@H_403_8@ normal function containing a string,ordinary string escaping rules@H_403_8@ apply; only newlines and the character used to quote the string need@H_403_8@ to be escaped.)

07005

The url() function supports specifying additional <url-modifier>s,@H_403_8@ which change the meaning or the interpretation of the URL somehow. A@H_403_8@ <url-modifier> is either an 07006 or a 07007.

This specification does not define any <url-modifier>s,but other@H_403_8@ specs may do so.

参见CSS Values and Units Module Level 3
Editor’s Draft,21 March 2016

>什么是< ident>的示例用法并在url()函数?@H_403_8@>< string>之间有什么区别? ,< ident>,在url()中的功能

解决方法

A <url-modifier> is either an <ident> or a function.

< ident>是一个标识符。

A portion of the CSS source that has the same Syntax as an <ident-token>.

<ident-token> Syntax ;

我找不到任何< ident>的例子在url函数中使用但是@H_403_8@如this email所述,有一些可能的未来用途。

>提取选项来控制CORS / cookies / etc@H_403_8@>使用子资源完整性

查看< ident>语法你不能使用键/值对,所以我假设@H_403_8@其中大部分将使用尚不存在的功能实现,资源提示可以使用< ident&gt ;.实现。 .foo {@H_403_8@background-image:url(“// aa.com/img.svg”prefetch);@H_403_8@}}

然而,我找到了一个“有趣的想法的集合”,其功能是< url-modifier>定义。

SVG Parameters(不是官方规格)

params()功能是< url-modifier>

.foo {background-image:url(“// aa.com/img.svg”param( – color var( – primary-color)));}}

猜你在找的CSS相关文章