diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/bottom | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/css/bottom')
-rw-r--r-- | files/zh-cn/web/css/bottom/index.html | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/bottom/index.html b/files/zh-cn/web/css/bottom/index.html new file mode 100644 index 0000000000..46195d386c --- /dev/null +++ b/files/zh-cn/web/css/bottom/index.html @@ -0,0 +1,161 @@ +--- +title: bottom +slug: Web/CSS/bottom +translation_of: Web/CSS/bottom +--- +<div>{{CSSRef}}</div> + +<p><strong><code>bottom</code></strong><a href="/zh-CN/docs/Web/CSS">样式</a>属性定义了定位元素下外边距边界与其包含块下边界之间的偏移,非定位元素设置此属性无效。</p> + +<p><code>bottom</code>的效果取决于元素的<code>position</code>属性:</p> + +<ul> + <li>当<code>position</code>设置为<code>absolute</code>或<code>fixed</code>时,<code>bottom</code>属性指定了定位元素下外边距边界与其包含块下边界之间的偏移。</li> + <li>当<code>position</code>设置为<code>relative</code>时,<code>bottom</code>属性指定了元素的下边界离开其正常位置的偏移。</li> + <li>当<code>position</code>设置为<code>sticky</code>时,如果元素在viewport里面,<code>bottom</code>属性的效果和position为<code>relative</code>等同;如果元素在viewport外面,<code>bottom</code>属性的效果和position为<code>fixed</code>等同。</li> + <li>当<code>position</code>设置为<code>static</code>时,<code>bottom</code>属性无效。</li> +</ul> + +<p>当 {{cssxref("top")}}和<code>bottom</code>同时指定时,并且 {{cssxref("height")}}没有被指定或者指定为<code>auto</code>或<code>100%</code>的时候,{{cssxref("top")}}和<code>bottom</code>都会生效,在其他情况下,如果 {{cssxref("height")}}被限制,则{{cssxref("top")}}属性会优先设置,<code>bottom</code>属性则会被忽略。</p> + +<p>{{cssinfo}}</p> + +<h2 id="Syntax" name="Syntax">语法</h2> + +<pre>/* <length> values */<code> +bottom: 3px; +bottom: 2.4em; + +/* <percentage>s of the height of the containing block */ +bottom: 10%; + +/* Keyword value */ +bottom: auto; + +/* Global values */ +bottom: inherit; +bottom: initial; +bottom: unset;</code></pre> + +<h3 id="值">值</h3> + +<ul> + <li>对于<strong>绝对定位的元素</strong>,元素下外边距边界与其包含块下边界之间的偏移。</li> + <li>对于<strong>相对定位定位的元素,</strong>元素的下边界离开其正常位置的偏移。</li> +</ul> + +<dl> + <dt><code><length></code></dt> + <dd><font face="Consolas, Liberation Mono, Courier, monospace">一个负值、空值或正值,代表了:</font></dd> + <dt><code><percentage></code></dt> + <dd>包含块高度的百分比{{cssxref("<percentage>")}}。</dd> + <dt><code>auto</code></dt> + <dd>规定: + <ul> + <li>对于绝对定位元素,元素将忽略此属性而以{{ Cssxref("top") }}属性为准,如果此时设置<code>height: auto</code>,将基于内容需要的高度设置宽度;如果<code>top</code>也为<code>auto</code>的话,元素的垂直位置就是它假如作为静态(即static)元素时该在的位置。</li> + <li>对于相对定位元素,元素相对正常位置的偏移量将基于{{ Cssxref("top") }}属性;如果<code>top</code>也为<code>auto</code>的话,元素将不会有偏移。</li> + </ul> + </dd> + <dt><code>inherit</code></dt> + <dd>指代有明确计算结果的父级元素的值,(需要注意的是,父级元素并不一定是包裹该子元素的块级元素)。该值会根据父级元素的具体情况被处理为{{cssxref("<length>")}}, {{cssxref("<percentage>")}}或者<code>auto</code>。</dd> +</dl> + +<h3 id="Formal_syntax">Formal syntax</h3> + +<pre class="syntaxbox">{{csssyntax}}</pre> + +<h2 id="Examples" name="Examples">示例</h2> + +<p>下面的例子分别展示了<code>bottom</code>属性在<code>position</code>为<code>absolute</code>和<code>fixed</code>的不同行为.</p> + +<h3 id="HTML">HTML</h3> + +<p> </p> + +<pre><code><p>This<br>is<br>some<br>tall,<br>tall,<br>tall,<br>tall,<br>tall<br>content.</p> +<div class="fixed"><p>Fixed</p></div> +<div class="absolute"><p>Absolute</p></div></code> +</pre> + +<p> </p> + +<p> </p> + +<h3 id="CSS">CSS</h3> + +<p> </p> + +<pre><code>p { + font-size: 30px; + line-height: 2em; +} + +div { + width: 48%; + text-align: center; + background: rgba(55,55,55,.2); + border: 1px solid blue; +} + +.absolute { + position: absolute; + bottom: 0; + left: 0; +} + +.fixed { + position: fixed; + bottom: 0; + right: 0; +}</code></pre> + +<p> </p> + +<p> </p> + +<h3 id="结果">结果</h3> + +<p>{{EmbedLiveSample('Example','500','250')}}</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', 'bottom')}}</td> + <td>{{Spec2('CSS3 Transitions')}}</td> + <td>Defines bottom as animatable.</td> + </tr> + <tr> + <td>{{SpecName('CSS3 Positioning', '#propdef-bottom', 'bottom')}}</td> + <td>{{Spec2('CSS3 Positioning')}}</td> + <td>Adds behavior for sticky positioning.</td> + </tr> + <tr> + <td>{{SpecName('CSS2.1', 'visuren.html#choose-position', 'bottom')}}</td> + <td>{{Spec2('CSS2.1')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> + +<p> </p> + +<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.bottom")}}</p> + +<p> </p> + +<div> </div> |