From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/css/background-origin/index.html | 169 +++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 files/zh-cn/web/css/background-origin/index.html (limited to 'files/zh-cn/web/css/background-origin') diff --git a/files/zh-cn/web/css/background-origin/index.html b/files/zh-cn/web/css/background-origin/index.html new file mode 100644 index 0000000000..3109f95def --- /dev/null +++ b/files/zh-cn/web/css/background-origin/index.html @@ -0,0 +1,169 @@ +--- +title: background-origin +slug: Web/CSS/background-origin +translation_of: Web/CSS/background-origin +--- +
{{CSSRef}}
+ +

摘要

+ +

 background-origin 规定了指定背景图片{{cssxref("background-image")}} 属性的原点位置的背景相对区域.

+ +

注意:当使用 {{Cssxref("background-attachment")}} 为fixed时,该属性将被忽略不起作用。

+ +
假如{{cssxref("background")}}简写中没有设置该值,那么在 background 简写值后指定background-origin,那么后面的值就会覆盖简写值,其实说白了,就是后出现的值会覆盖前面的值。
+ +

{{cssinfo}}

+ +

语法

+ +
Formal syntax: {{csssyntax("background-origin")}}
+ +
background-origin: border-box
+background-origin: padding-box
+background-origin: content-box
+
+background-origin: inherit
+
+ +

属性值

+ +
+
border-box
+
背景图片的摆放以border区域为参考
+
padding-box
+
背景图片的摆放以padding区域为参考
+
content-box
+
背景图片的摆放以content区域为参考
+
+

形式化语法

+ How to read CSS syntax. + +
{{csssyntax("background-origin")}}
+
+
+ +

例子

+ +
 .example {
+   border: 10px double;
+   padding: 10px;
+   background: url('image.jpg');
+   background-position: center left;
+   /* 背景将在内容区padding内部填充 */
+   background-origin: content-box;
+}
+
+ +
#example2 {
+    border: 4px solid black;
+    padding: 10px;
+    background: url('image.gif');
+    background-repeat: no-repeat;
+    background-origin: border-box;
+ }
+ +
div {
+  background-image: url('logo.jpg'), url('mainback.png');
+  background-position: top right, 0px 0px;
+  background-origin: content-box, padding-box;
+}
+ +

规范

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Backgrounds', '#the-background-origin', 'background-origin')}}{{Spec2('CSS3 Backgrounds')}} 
+ +

浏览器兼容性

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support1.0 [3]{{CompatGeckoDesktop("2.0")}} [1]9.0 [2]10.53.0 (522) [3]
content-box1.0 [3]{{CompatGeckoDesktop("2.0")}} [1]9.0 [2]{{CompatNo}}3.0 (522) [3]
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
content-box{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

[1] Gecko supported, from version 1.1 to version 1.9.2, which corresponds to Firefox 1.0 to 3.6 included, a different, and prefixed, syntax: -moz-background-origin: padding | border.

+ +

[2] Internet Explorer up to version 7 behaves as if there was a background-origin: border-box; Internet Explorer 8 behaves as if it were background-origin: padding-box; which is the regular default value.

+ +

[3] Webkit also supports the prefixed version of this proprietary, and in that case, in addition to the current keywords, the alternative synonyms: padding, border, and content.

+ +

[4] Konqueror 3.5.4 supports -khtml-background-origin.

+ +

相关文献

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