使用@import时的子资源完整性 [英] Subresource Integrity when using @import
问题描述
使用@import时包含子资源完整性的语法是什么?
What is the syntax to include subresource integrity when using @import?
@import url(//use.fontawesome.com/releases/v5.3.1/css/all.css);
基本上,当使用上述的 @import
时,如何包括子资源的完整性和跨域参数?
Besically how do I include the subresource integrity and crossorigin parameters when using @import
like above?
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
推荐答案
TL; DR :SRI是一种浏览器,CSS规则(如@import)是一个css.
TL;DR: SRI is a browser-thing, CSS at-rules (like @import) are a css-thing.
使用@import时包含子资源完整性的语法是什么?
What is the syntax to include subresource integrity when using @import?
据我所知,当前的CSS规范(撰写本文时起草了CSS3)没有任何内容-定义了@import的用法-详细说明了CSS的SRI用法.
From what I can tell, there is nothing in the current CSS spec (CSS3 drafted as of writing this) - where usage of @import is defined - that details usage of SRI for css.
基本上,当使用上述@import时,如何包括子资源的完整性和跨域参数?
Besically how do I include the subresource integrity and crossorigin parameters when using @import like above?
这些参数定义浏览器如何获取资源并解释其合法性.这是在实现资源(js,css等)之前发生的.
Those parameters define how the browser fetches the resource and interprets its legitimacy. This happens before the resource is implemented (js, css, etc.).
外部资源:
- CSS3规范草案(特定于常规用法):https://drafts.csswg.org/css-cascade-3/#at-ruledef-import
- 有关@import用法的MDN页面: https://developer.mozilla.org/zh-CN/docs/Web/CSS/@ import
- 详细介绍SRI的MDN页面: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
这篇关于使用@import时的子资源完整性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!