Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

@import

这篇翻译不完整。请帮忙从英语翻译这篇文章

概述

@importCSS@规则,用于加载外部层叠样式表。@import规则必须放在其他除了@charset规则以外的CSS规则的前面;@import规则不可嵌套条件规则组中。

@import可在URI后面附带媒体查询;每条媒体查询间用逗号分隔。若没有媒体查询,则该导入是无条件的,相当于指定媒体为all

语法

@import url;
@import url list-of-media-queries;

其中:

url
Is a <string> or a <uri> representing the location of the resource to import. The URL may be absolute or relative. Note that the URL need not actually specify a file; it can just specify the package name and part, and the appropriate file is chosen automatically (e.g. chrome://communicator/skin/). See here for more information.
list-of-media-queries
Is a comma-separated list of 媒体查询 conditioning the application of the CSS 规则 defined in the linked URL. If the browser does not 支持 any these queries, it does not load the linked resource.

正规语法

@import [ <string> | <url> ] [<media-query-list>]?;

示例

@import url("fineprint.css") print;
@import url("bluish.css") projection, tv;
@import 'custom.css';
@import url("chrome://communicator/skin/");
@import "common.css" screen, projection;
@import url('landscape.css') screen and (orientation:landscape);

技术规格

技术规格 Status 备注
Media Queries
@import
Recommendation 扩展语法以支持任何媒体查询,而不仅仅是简单的媒体类型
CSS Level 2 (Revision 1)
@import
Recommendation 支持用<string>直接表示样式表的url,
并要求@import规则必须在CSS文档的开头。
CSS Level 1
@import
Recommendation 初始定义

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) 5.5 (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) 5.5 (Yes) (Yes)

文档标签和贡献者

标签: 
 此页面的贡献者: Guillaume-Heras, mrstork, gqqnbig
 最后编辑者: Guillaume-Heras,