From bbed12e574958e07af25518c7e66bd5ee2fb2d2c Mon Sep 17 00:00:00 2001 From: MDN Date: Wed, 9 Jun 2021 00:40:02 +0000 Subject: [CRON] sync translated content --- files/zh-cn/_redirects.txt | 6 +- files/zh-cn/_wikihistory.json | 32 ++++----- .../web/api/elementcssinlinestyle/style/index.html | 81 ++++++++++++++++++++++ .../orphaned/web/api/request/context/index.html | 44 ++++++++++++ .../web/api/elementcssinlinestyle/style/index.html | 81 ---------------------- files/zh-cn/web/api/request/context/index.html | 43 ------------ 6 files changed, 145 insertions(+), 142 deletions(-) create mode 100644 files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html create mode 100644 files/zh-cn/orphaned/web/api/request/context/index.html delete mode 100644 files/zh-cn/web/api/elementcssinlinestyle/style/index.html delete mode 100644 files/zh-cn/web/api/request/context/index.html (limited to 'files/zh-cn') diff --git a/files/zh-cn/_redirects.txt b/files/zh-cn/_redirects.txt index 410196f470..ed7e0d8b5f 100644 --- a/files/zh-cn/_redirects.txt +++ b/files/zh-cn/_redirects.txt @@ -1547,6 +1547,7 @@ /zh-CN/docs/Web/API/Element/onpaste /zh-CN/docs/Web/API/HTMLElement/onpaste /zh-CN/docs/Web/API/Element/removeAttributre /zh-CN/docs/Web/API/Element/removeAttribute /zh-CN/docs/Web/API/Element/runtimeStyle /zh-CN/docs/orphaned/Web/API/Element/runtimeStyle +/zh-CN/docs/Web/API/ElementCSSInlineStyle/style /zh-CN/docs/orphaned/Web/API/ElementCSSInlineStyle/style /zh-CN/docs/Web/API/Entity /zh-CN/docs/orphaned/Web/API/Entity /zh-CN/docs/Web/API/Event/CustomEvent /zh-CN/docs/Web/API/CustomEvent /zh-CN/docs/Web/API/Event/altKey /zh-CN/docs/conflicting/Web/API/MouseEvent/altKey @@ -1616,7 +1617,7 @@ /zh-CN/docs/Web/API/HTMLElement.offsetParent /zh-CN/docs/Web/API/HTMLElement/offsetParent /zh-CN/docs/Web/API/HTMLElement.offsetTop /zh-CN/docs/Web/API/HTMLElement/offsetTop /zh-CN/docs/Web/API/HTMLElement.offsetWidth /zh-CN/docs/Web/API/HTMLElement/offsetWidth -/zh-CN/docs/Web/API/HTMLElement.style /zh-CN/docs/Web/API/ElementCSSInlineStyle/style +/zh-CN/docs/Web/API/HTMLElement.style /zh-CN/docs/orphaned/Web/API/ElementCSSInlineStyle/style /zh-CN/docs/Web/API/HTMLElement.tabIndex /zh-CN/docs/Web/API/HTMLOrForeignElement/tabIndex /zh-CN/docs/Web/API/HTMLElement.title /zh-CN/docs/Web/API/HTMLElement/title /zh-CN/docs/Web/API/HTMLElement/blur /zh-CN/docs/Web/API/HTMLOrForeignElement/blur @@ -1624,7 +1625,7 @@ /zh-CN/docs/Web/API/HTMLElement/focus /zh-CN/docs/Web/API/HTMLOrForeignElement/focus /zh-CN/docs/Web/API/HTMLElement/forceSpellCheck /zh-CN/docs/orphaned/Web/API/HTMLElement/forceSpellCheck /zh-CN/docs/Web/API/HTMLElement/nonce /zh-CN/docs/Web/API/HTMLOrForeignElement/nonce -/zh-CN/docs/Web/API/HTMLElement/style /zh-CN/docs/Web/API/ElementCSSInlineStyle/style +/zh-CN/docs/Web/API/HTMLElement/style /zh-CN/docs/orphaned/Web/API/ElementCSSInlineStyle/style /zh-CN/docs/Web/API/HTMLElement/tabIndex /zh-CN/docs/Web/API/HTMLOrForeignElement/tabIndex /zh-CN/docs/Web/API/HTMLFormElement.elements /zh-CN/docs/Web/API/HTMLFormElement/elements /zh-CN/docs/Web/API/HTMLFormElement.reset /zh-CN/docs/Web/API/HTMLFormElement/reset @@ -1752,6 +1753,7 @@ /zh-CN/docs/Web/API/RTCPeerConnection/getDefaultIceServers /zh-CN/docs/orphaned/Web/API/RTCPeerConnection/getDefaultIceServers /zh-CN/docs/Web/API/RandomSource /zh-CN/docs/conflicting/Web/API/Crypto/getRandomValues /zh-CN/docs/Web/API/RandomSource/getRandomValues /zh-CN/docs/Web/API/Crypto/getRandomValues +/zh-CN/docs/Web/API/Request/context /zh-CN/docs/orphaned/Web/API/Request/context /zh-CN/docs/Web/API/Response/克隆 /zh-CN/docs/Web/API/Response/clone /zh-CN/docs/Web/API/SVGPathElement/getTotalLength /zh-CN/docs/Web/API/SVGGeometryElement/getTotalLength /zh-CN/docs/Web/API/Screen.availHeight /zh-CN/docs/Web/API/Screen/availHeight diff --git a/files/zh-cn/_wikihistory.json b/files/zh-cn/_wikihistory.json index a806ad7579..4b5d22d492 100644 --- a/files/zh-cn/_wikihistory.json +++ b/files/zh-cn/_wikihistory.json @@ -13039,16 +13039,6 @@ "ziyunfei" ] }, - "Web/API/ElementCSSInlineStyle/style": { - "modified": "2020-10-15T21:30:08.559Z", - "contributors": [ - "zhuangyin", - "xgqfrms-GitHub", - "distums", - "teoli", - "AlexChao" - ] - }, "Web/API/ErrorEvent": { "modified": "2020-10-15T21:38:19.894Z", "contributors": [ @@ -19836,12 +19826,6 @@ "sixpencecl" ] }, - "Web/API/Request/context": { - "modified": "2020-10-15T22:30:43.048Z", - "contributors": [ - "Aliom252181" - ] - }, "Web/API/Request/credentials": { "modified": "2020-10-15T21:53:30.490Z", "contributors": [ @@ -50227,6 +50211,16 @@ "jiangyuzhen" ] }, + "orphaned/Web/API/ElementCSSInlineStyle/style": { + "modified": "2020-10-15T21:30:08.559Z", + "contributors": [ + "zhuangyin", + "xgqfrms-GitHub", + "distums", + "teoli", + "AlexChao" + ] + }, "orphaned/Web/API/Entity": { "modified": "2020-06-03T01:07:43.853Z", "contributors": [ @@ -50370,6 +50364,12 @@ "lauhua" ] }, + "orphaned/Web/API/Request/context": { + "modified": "2020-10-15T22:30:43.048Z", + "contributors": [ + "Aliom252181" + ] + }, "orphaned/Web/API/TextRange/text": { "modified": "2020-02-26T01:25:35.461Z", "contributors": [ diff --git a/files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html b/files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html new file mode 100644 index 0000000000..fae28c710d --- /dev/null +++ b/files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html @@ -0,0 +1,81 @@ +--- +title: HTMLElement.style +slug: orphaned/Web/API/ElementCSSInlineStyle/style +translation_of: Web/API/ElementCSSInlineStyle/style +original_slug: Web/API/ElementCSSInlineStyle/style +--- +
{{ APIRef("HTML DOM") }}
+ +

HTMLElement.style 属性返回一个 CSSStyleDeclaration 对象,表示元素的 内联style 属性(attribute),但忽略任何样式表应用的属性。 通过 style 可以访问的 CSS 属性列表,可以查看 CSS Properties Reference

+ +

由于 style 属性的优先级和通过style设置内联样式是一样的,并且在css层级样式中拥有最高优先级,因此在为特定的元素设置样式时很有用。

+ +

设置 style 属性

+ +

注意不能通过直接给style属性设置字符串(如:elt.style = "color: blue;")来设置style,因为style应被当成是只读的(尽管Firefox(Gecko), Chrome 和 Opera允许修改它),这是因为通过style属性返回的CSSStyleDeclaration对象是只读的。但是style属性本身的属性够用来设置样式。此外,通过单独的样式属性(如elt.style.color = '...')比用elt.style.cssText = '...' 或者 elt.setAttribute('style', '...')形式更加简便,除非你希望完全通过一个单独语句来设置元素的全部样式,因为通过style本身属性设置的样式不会影响到通过其他方式设置的其他css属性的样式。

+ +

例子

+ +
// 在单个语句中设置多个样式
+elt.style.cssText = "color: blue; border: 1px solid black";
+// 或者
+elt.setAttribute("style", "color:red; border: 1px solid blue;");
+
+// 设置特定样式,同时保持其他内联样式值不变
+elt.style.color = "blue";
+
+ +

获取元素样式信息

+ +

通常,要了解元素样式的信息,仅仅使用 style 属性是不够的,这是因为它只包含了在元素内嵌 style 属性(attribute)上声明的的 CSS 属性,而不包括来自其他地方声明的样式,如 {{HTMLElement("head")}} 部分的内嵌样式表,或外部样式表。要获取一个元素的所有 CSS 属性,你应该使用 {{domxref("window.getComputedStyle()")}}。

+ +
<!DOCTYPE HTML>
+<html>
+<body style="font-weight:bold;">
+
+    <div style="color:red" id="myElement">..</div>
+
+ </body>
+</html>
+ +

下面的代码输出 style 所有属性的名字,以及为元素 elt 显式设置的属性值和继承的计算值(computed value):

+ +
var element = document.getElementById("myElement");
+var out = "";
+var elementStyle = element.style;
+var computedStyle = window.getComputedStyle(element, null);
+
+for (prop in elementStyle) {
+  if (elementStyle.hasOwnProperty(prop)) {
+    out += "  " + prop + " = '" + elementStyle[prop] + "' > '" + computedStyle[prop] + "'\n";
+  }
+}
+console.log(out)
+ +

输出结果如下:

+ +
...
+fontWeight = '' > 'bold'
+color = 'red' > 'rgb(255, 0, 0)'
+...
+
+ +

请注意,计算样式中font-weight的值为“bold”,元素的style属性中缺少该值

+ +

规范

+ +

DOM Level 2 Style: ElementCSSInlineStyle.style

+ +

CSSOM: ElementCSSInlineStyle

+ +

兼容性

+ + + +

{{Compat("api.HTMLElement.style")}}

+ +

相关链接

+ + diff --git a/files/zh-cn/orphaned/web/api/request/context/index.html b/files/zh-cn/orphaned/web/api/request/context/index.html new file mode 100644 index 0000000000..202367fba6 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/request/context/index.html @@ -0,0 +1,44 @@ +--- +title: Request.context +slug: orphaned/Web/API/Request/context +translation_of: Web/API/Request/context +original_slug: Web/API/Request/context +--- +
{{APIRef("Fetch")}}{{deprecated_header()}}
+ +

The deprecated 弃用context所述的只读属性{{domxref("请求")}}接口包含请求的上下文(例如,audioimageiframe)。这定义了要获取的资源类型。它已由{{domxref("Request.destination”,“ destination")}}属性取代。 This defines what sort of resource is being fetched. This has been replaced by the {{domxref("Request.destination", "destination")}} property.

+ +

The context of a request is only relevant in the 请求的上下文仅与ServiceWorker API相关服务人员可以根据URL是用于图像还是可嵌入对象(例如{{htmlelement("视频")}},{{domxref("iframe")}}等)进行决策。; a service worker can make decisions based on whether the URL is for an image, or an embeddable object such as a {{htmlelement("video")}}, {{domxref("iframe")}}, etc.

+ +
+

Note注意:您可以在“ 获取规范请求上下文”部分中找到不同可用上下文的完整列表,包括关联的上下文框架类型,CSP指令和平台功能示例 section.

+
+ +

Syntax

+ +
var myContext = request.context;
+ +

Value

+ +

A {{domxref("RequestContext")}} value.一个{{domxref("RequestContext")}}值。

+ +

Example例子

+ +

In the following snippet, we create a new request using the {{domxref("Request.Request()")}} constructor (for an image file in the same directory as the script), then save the request context in a variable:在以下代码段中,我们使用{{domxref("Request.Request()")}}}构造函数创建一个新请求(用于与脚本位于同一目录中的图像文件),然后将请求上下文保存在变量中:

+ +
var myRequest = new Request('flowers.jpg');
+var myContext = myRequest.context; // returns the empty string by default
+ +

Browser compatibility浏览器兼容性

+ + + +

{{Compat("api.Request.context")}}

+ +

更多

+ + diff --git a/files/zh-cn/web/api/elementcssinlinestyle/style/index.html b/files/zh-cn/web/api/elementcssinlinestyle/style/index.html deleted file mode 100644 index 28248babe1..0000000000 --- a/files/zh-cn/web/api/elementcssinlinestyle/style/index.html +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: HTMLElement.style -slug: Web/API/ElementCSSInlineStyle/style -translation_of: Web/API/ElementCSSInlineStyle/style -original_slug: Web/API/HTMLElement/style ---- -
{{ APIRef("HTML DOM") }}
- -

HTMLElement.style 属性返回一个 CSSStyleDeclaration 对象,表示元素的 内联style 属性(attribute),但忽略任何样式表应用的属性。 通过 style 可以访问的 CSS 属性列表,可以查看 CSS Properties Reference

- -

由于 style 属性的优先级和通过style设置内联样式是一样的,并且在css层级样式中拥有最高优先级,因此在为特定的元素设置样式时很有用。

- -

设置 style 属性

- -

注意不能通过直接给style属性设置字符串(如:elt.style = "color: blue;")来设置style,因为style应被当成是只读的(尽管Firefox(Gecko), Chrome 和 Opera允许修改它),这是因为通过style属性返回的CSSStyleDeclaration对象是只读的。但是style属性本身的属性够用来设置样式。此外,通过单独的样式属性(如elt.style.color = '...')比用elt.style.cssText = '...' 或者 elt.setAttribute('style', '...')形式更加简便,除非你希望完全通过一个单独语句来设置元素的全部样式,因为通过style本身属性设置的样式不会影响到通过其他方式设置的其他css属性的样式。

- -

例子

- -
// 在单个语句中设置多个样式
-elt.style.cssText = "color: blue; border: 1px solid black";
-// 或者
-elt.setAttribute("style", "color:red; border: 1px solid blue;");
-
-// 设置特定样式,同时保持其他内联样式值不变
-elt.style.color = "blue";
-
- -

获取元素样式信息

- -

通常,要了解元素样式的信息,仅仅使用 style 属性是不够的,这是因为它只包含了在元素内嵌 style 属性(attribute)上声明的的 CSS 属性,而不包括来自其他地方声明的样式,如 {{HTMLElement("head")}} 部分的内嵌样式表,或外部样式表。要获取一个元素的所有 CSS 属性,你应该使用 {{domxref("window.getComputedStyle()")}}。

- -
<!DOCTYPE HTML>
-<html>
-<body style="font-weight:bold;">
-
-    <div style="color:red" id="myElement">..</div>
-
- </body>
-</html>
- -

下面的代码输出 style 所有属性的名字,以及为元素 elt 显式设置的属性值和继承的计算值(computed value):

- -
var element = document.getElementById("myElement");
-var out = "";
-var elementStyle = element.style;
-var computedStyle = window.getComputedStyle(element, null);
-
-for (prop in elementStyle) {
-  if (elementStyle.hasOwnProperty(prop)) {
-    out += "  " + prop + " = '" + elementStyle[prop] + "' > '" + computedStyle[prop] + "'\n";
-  }
-}
-console.log(out)
- -

输出结果如下:

- -
...
-fontWeight = '' > 'bold'
-color = 'red' > 'rgb(255, 0, 0)'
-...
-
- -

请注意,计算样式中font-weight的值为“bold”,元素的style属性中缺少该值

- -

规范

- -

DOM Level 2 Style: ElementCSSInlineStyle.style

- -

CSSOM: ElementCSSInlineStyle

- -

兼容性

- - - -

{{Compat("api.HTMLElement.style")}}

- -

相关链接

- - diff --git a/files/zh-cn/web/api/request/context/index.html b/files/zh-cn/web/api/request/context/index.html deleted file mode 100644 index 98730ceb60..0000000000 --- a/files/zh-cn/web/api/request/context/index.html +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: Request.context -slug: Web/API/Request/context -translation_of: Web/API/Request/context ---- -
{{APIRef("Fetch")}}{{deprecated_header()}}
- -

The deprecated 弃用context所述的只读属性{{domxref("请求")}}接口包含请求的上下文(例如,audioimageiframe)。这定义了要获取的资源类型。它已由{{domxref("Request.destination”,“ destination")}}属性取代。 This defines what sort of resource is being fetched. This has been replaced by the {{domxref("Request.destination", "destination")}} property.

- -

The context of a request is only relevant in the 请求的上下文仅与ServiceWorker API相关服务人员可以根据URL是用于图像还是可嵌入对象(例如{{htmlelement("视频")}},{{domxref("iframe")}}等)进行决策。; a service worker can make decisions based on whether the URL is for an image, or an embeddable object such as a {{htmlelement("video")}}, {{domxref("iframe")}}, etc.

- -
-

Note注意:您可以在“ 获取规范请求上下文”部分中找到不同可用上下文的完整列表,包括关联的上下文框架类型,CSP指令和平台功能示例 section.

-
- -

Syntax

- -
var myContext = request.context;
- -

Value

- -

A {{domxref("RequestContext")}} value.一个{{domxref("RequestContext")}}值。

- -

Example例子

- -

In the following snippet, we create a new request using the {{domxref("Request.Request()")}} constructor (for an image file in the same directory as the script), then save the request context in a variable:在以下代码段中,我们使用{{domxref("Request.Request()")}}}构造函数创建一个新请求(用于与脚本位于同一目录中的图像文件),然后将请求上下文保存在变量中:

- -
var myRequest = new Request('flowers.jpg');
-var myContext = myRequest.context; // returns the empty string by default
- -

Browser compatibility浏览器兼容性

- - - -

{{Compat("api.Request.context")}}

- -

更多

- - -- cgit v1.2.3-54-g00ecf