aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/object-position/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/object-position/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/css/object-position/index.html')
-rw-r--r--files/zh-cn/web/css/object-position/index.html118
1 files changed, 118 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/object-position/index.html b/files/zh-cn/web/css/object-position/index.html
new file mode 100644
index 0000000000..cb4f8d6bdf
--- /dev/null
+++ b/files/zh-cn/web/css/object-position/index.html
@@ -0,0 +1,118 @@
+---
+title: object-position
+slug: Web/CSS/object-position
+tags:
+ - CSS
+ - CSS属性
+ - object-position
+translation_of: Web/CSS/object-position
+---
+<div>{{CSSRef}}</div>
+
+<p><a href="/zh-CN/docs/Web/CSS">CSS</a> 属性 <strong><code>object-position</code></strong> 规定了<a href="/zh-CN/docs/Web/CSS/Replaced_element">可替换元素</a>的内容,在这里我们称其为对象(即 <strong><code>object-position</code></strong> 中的 <strong><code>object</code>)</strong>,在其内容框中的位置。可替换元素的内容框中未被对象所覆盖的部分,则会显示该元素的背景({{cssxref("background")}})。</p>
+
+<p>你还可以使用 {{cssxref("object-fit")}} 属性来改变可替换元素的对象的内在(原文:intrinsic)大小(即它看上去的大小)的调整方式,借助拉伸与缩放等使对象更好地适应元素的内容框。</p>
+
+<div>{{EmbedInteractiveExample("pages/css/object-position.html")}}</div>
+
+
+
+<h2 id="语法">语法</h2>
+
+<pre class="brush:css no-line-numbers">/* &lt;position&gt; values */
+object-position: center top;
+object-position: 100px 50px;
+
+/* Global values */
+object-position: inherit;
+object-position: initial;
+object-position: unset;
+</pre>
+
+<h3 id="取值">取值</h3>
+
+<dl>
+ <dt>{{cssxref("&lt;position&gt;")}}</dt>
+ <dd>使用 1 到 4 个值来定义该元素在它所处的二维平面中的定位。可以使用相对或绝对偏移。</dd>
+</dl>
+
+<div class="note">
+<p><strong>注意:</strong>这些定位方式允许被替换元素的对象被定位到内容框外部。</p>
+</div>
+
+<h3 id="正式语法">正式语法</h3>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="例子">例子</h2>
+
+<h3 id="HTML">HTML</h3>
+
+<p>Here we see HTML that includes two {{HTMLElement("img")}} elements, each displaying the MDN logo.</p>
+
+<p>这里我们看到包含两个img元素的HTML,分别展示了MDN的logo</p>
+
+<pre class="brush: html">&lt;img id="object-position-1" src="https://mdn.mozillademos.org/files/12668/MDN.svg" alt="MDN Logo"/&gt;
+&lt;img id="object-position-2" src="https://mdn.mozillademos.org/files/12668/MDN.svg" alt="MDN Logo"/&gt;
+</pre>
+
+<h3 id="CSS">CSS</h3>
+
+<p>CSS包括&lt;img&gt;元素本身的默认样式,以及两个图像各自的样式。</p>
+
+<pre class="brush: css">img {
+ width: 300px;
+ height: 250px;
+ border: 1px solid black;
+ background-color: silver;
+ margin-right: 1em;
+ object-fit: none;
+}
+
+#object-position-1 {
+ object-position: 10px;
+}
+
+#object-position-2 {
+ object-position: 100% 10%;
+}
+</pre>
+
+<p>第一个图像的左边缘距元素框左边缘10个像素。第二个图像的右边缘与元素框的右边缘齐平,并位于元素框高度下方10%处。</p>
+
+<h3 id="输出">输出</h3>
+
+<p>{{ EmbedLiveSample('Example', '100%','300px') }}</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('CSS3 Images', '#the-object-position', 'object-position')}}</td>
+ <td>{{Spec2('CSS3 Images')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("css.properties.object-position")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>其他与图像相关的 CSS 属性: {{cssxref("object-fit")}},{{cssxref("image-orientation")}},{{cssxref("image-rendering")}},{{cssxref("image-resolution")}}。</li>
+</ul>