Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

bottom

这篇翻译不完整。请帮忙从英语翻译这篇文章

简介

bottom属性用来指定被定位元素的位置。

对于绝对定位的元素,即 position属性设置为absolute或者fixed的元素,bottom属性指定元素底边距边缘和包含该元素的容器的底边缘的距离。

对于相对定位的元素,即position属性设置为relative的元素,bottom属性指定元素的下边界离开其正常位置的距离。

top和bottom同时出现,并且 height没定义或者为auto或100%的时候,top和bottom都会生效,在其他情况下,如果 height被限制,则top属性会优先设置bottom属性会被忽略。

初始值auto
适用元素positioned elements
是否是继承属性
Percentagesrefer to the height of the containing block
适用媒体visual
计算值if specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, auto
是否适用于 CSS 动画yes, as a length, percentage or calc(); when both values are lengths, they are interpolated as lengths; when both values are percentages, they are interpolated as percentages; otherwise, both values are converted into a calc() function that is the sum of a length and a percentage (each possibly zero), and these calc() functions have each half interpolated as real numbers.
正规顺序the unique non-ambiguous order defined by the formal grammar

Syntax

/* <length> values */
bottom: 3px;
bottom: 2.4em;

/* <percentages> of the height of the containing block */
bottom: 10%;

/* keyword values */
bottom: auto;
bottom: inherit;

  • 对于绝对定位的元素,是与包含该元素的容器的底部边界的距离。
  • 对于相对定位的元素,是距离其未定位之前在正常流时位置的偏移量
<length>
一个负值、空值或正值:
<percentage>
包含块高度的百分比<percentage>,像在简介中描述的一样使用。
auto
Specifies that:
  • for absolutely positioned elements, the position of the element is based on the top property, and height: auto is treated as a height based on the content.
  • for relatively positioned elements, the offset the element from its original position is based on the top property, or if top is also auto, the element is not moved vertically at all.
inherit
Indicates that the value is the same as the computed value from its parent element (which may not be its containing block). This computed value is then handled as if it were a <length>, <percentage>, or the auto keyword.

Formal syntax

<length> | <percentage> | auto

Examples

element { 
    position: absolute;
    bottom: 20px; 
    height: 200px;
    border: 1px solid #000;
}

The following sample demonstrates the difference in behavior of the bottom property when position is absolute versus fixed. When the regular text becomes taller than the viewable portion of the page (that is, the browser window's viewport), blocks positioned with position:absolute scroll with the page, while blocks positioned with position:fixed don't.

<!DOCTYPE html>
<html>
<head>
<title>Position at bottom, absolute or fixed</title>
<style type="text/css">
p {font-size:30px; line-height:3em;}
div.pos {width:49%; text-align:center; border:2px solid #00f;}
div#abs {position:absolute; bottom:0; left:0;}
div#fix {position:fixed; bottom:0; right:0;}
</style>
</head>
<body>
  <p>This<br>is<br>some<br>tall,<br>tall,
    <br>tall,<br>tall,<br>tall<br>content.</p>
  <div id="fix" class="pos"><p>Fixed</p></div>
  <div id="abs" class="pos"><p>Absolute</p></div>
</body>
</html>

Specifications

Specification Status Comment
CSS Level 2 (Revision 1)
bottom
Recommendation Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 1.0 (1.7 or earlier) 5[1] 6 1.0 (85)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? 1.0 (1.9.2) ? ? ?

[1] In Internet Explorer versions before 7.0, when both top and bottom are specified, the element position is over-constrained and the top property has precedence. In that case the computed value of bottom is set to -top, while its specified value is ignored.

文档标签和贡献者

 此页面的贡献者: Sebastianz, Gavin_Yang
 最后编辑者: Sebastianz,