aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/right
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/right
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/right')
-rw-r--r--files/zh-cn/web/css/right/index.html131
1 files changed, 131 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/right/index.html b/files/zh-cn/web/css/right/index.html
new file mode 100644
index 0000000000..79559cebac
--- /dev/null
+++ b/files/zh-cn/web/css/right/index.html
@@ -0,0 +1,131 @@
+---
+title: right
+slug: Web/CSS/right
+translation_of: Web/CSS/right
+---
+<div>{{CSSRef}}</div>
+
+<p><strong><code>right</code></strong><a href="https://developer.mozilla.org/zh-CN/docs/Web/CSS">样式</a>属性定义了定位元素的右外边距边界与其包含块右边界之间的偏移,非定位元素设置此属性无效。</p>
+
+<pre class="brush: css"><code>/* &lt;length&gt; values */
+right: 3px;
+right: 2.4em;
+
+/* &lt;percentage&gt;s of the width of the containing block */
+right: 10%;
+
+/* Keyword value */
+right: auto;
+
+/* Global values */
+right: inherit;
+right: initial;
+right: unset;</code>
+</pre>
+
+<p><code>right</code>的效果取决于元素的<code>position</code>属性:</p>
+
+<ul>
+ <li>当<code>position</code>设置为<code>absolute</code>或<code>fixed</code>时,<code>right</code>属性指定了定位元素右外边距边界与其包含块右边界之间的偏移。</li>
+ <li>当<code>position</code>设置为<code>relative</code>时,<code>right</code>属性指定了元素的右边界离开其正常位置的偏移。</li>
+ <li>当<code>position</code>设置为<code>sticky</code>时,如果元素在viewport里面,<code>right</code>属性的效果和position为<code>relative</code>等同;如果元素在viewport外面,<code>right</code>属性的效果和position为<code>fixed</code>等同。</li>
+ <li>当<code>position</code>设置为<code>static</code>时,<code>right</code>属性无效。</li>
+</ul>
+
+<p>当{{cssxref("left")}}​​​​​​和<font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">right</span></font>同时指定时,元素的位置会被重复指定。当容器是从左到右时,<code>left</code>的值会被优先设定;当容器是从右到左时,<code>right</code>的值会被优先设定。</p>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<h3 id="取值">取值</h3>
+
+<dl>
+ <dt>{{cssxref("&lt;length&gt;")}}</dt>
+ <dd>可以是负的,正的 或者 null {{cssxref("&lt;length&gt;")}} 表示:
+ <ul>
+ <li>对于<strong>绝对定位的元素</strong>,元素右外边距边界与其包含块右边界之间的偏移。</li>
+ <li>对于<strong>相对定位定位的元素,</strong>元素的右边界离开其正常位置的偏移。</li>
+ </ul>
+ </dd>
+ <dt>{{cssxref("&lt;percentage&gt;")}}</dt>
+ <dd>代表元素包含块的宽度的百分比 {{cssxref("&lt;percentage&gt;")}}。</dd>
+ <dt><code>auto</code></dt>
+ <dd>这个关键字表示:
+ <ul>
+ <li>对于绝对定位元素,元素将忽略此属性而以{{ Cssxref("left") }}属性为准,如果此时设置<code>width: auto</code>,将基于内容需要的宽度设置宽度;如果<code>left</code>也为<code>auto</code>的话,元素的水平位置就是它假如作为静态(即static)元素时该在的位置。</li>
+ <li>对于相对定位元素,元素相对正常位置的偏移量将基于{{ Cssxref("left") }}属性;如果<code>left</code>也为 <code>auto</code>的话,元素将不会有偏移。</li>
+ </ul>
+ </dd>
+ <dt><code>inherit</code></dt>
+ <dd>这个关键字表示该值与其父元素 (可能不是它的包含块) 的计算值相同。对这个计算值的处理将和它原本为 {{cssxref("&lt;length&gt;")}}, {{cssxref("&lt;percentage&gt;")}} 或 <code>auto</code> 一样。</dd>
+</dl>
+
+<h3 id="Formal_syntax">Formal syntax</h3>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="Examples" name="Examples"><strong>示例</strong></h2>
+
+<pre class="brush: css; highlight:[16]">#example_3 {
+  width: 100px;
+  height: 100px;
+  background-color: #FFC7E4;
+  position: relative;
+  top: 20px;
+  left: 20px;
+}
+
+#example_4 {
+  width: 100px;
+  height: 100px;
+  background-color: #FFD7C2;
+  position: absolute;
+  bottom: 10px;
+  right: 20px;
+}</pre>
+
+<pre class="brush: html">&lt;div id="example_3"&gt;Example 3&lt;/div&gt;
+&lt;div id="example_4"&gt;Example 4&lt;/div&gt;
+</pre>
+
+<p>{{ EmbedLiveSample('Examples', 500, 220) }}</p>
+
+<h2 id="Specifications" name="Specifications">规范</h2>
+
+<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 Transitions', '#animatable-css', 'right')}}</td>
+ <td>{{Spec2('CSS3 Transitions')}}</td>
+ <td>Defines <code>right</code>as animatable.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS3 Positioning', '#propdef-right', 'right')}}</td>
+ <td>{{Spec2('CSS3 Positioning')}}</td>
+ <td>Adds behavior for sticky positioning.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS2.1', 'visuren.html#propdef-right', 'right')}}</td>
+ <td>{{Spec2('CSS2.1')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div class="hidden">
+<p>The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+</div>
+
+<p>{{Compat("css.properties.right")}}</p>
+
+<div id="compat-mobile"> </div>