MDN will be in maintenance mode on Thursday September 21st, starting at 10 AM Pacific / 5 PM UTC, for about 1 hour.




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


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

适用元素positioned elements
Percentagesrefer to the height of the containing block
计算值if specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, auto
Animation typea length, percentage or calc();
正规顺序the unique non-ambiguous order defined by the formal grammar


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

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

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

  • 对于绝对定位的元素,是与包含该元素的容器的底部边界的距离。
  • 对于相对定位的元素,是距离其未定位之前在正常流时位置的偏移量
Specifies that:
  • 对于 已绝对定位的元素, 元素的定位基于topheight: auto ,则高度由内容决定。
  • 对于 已相对定位定位的元素, 相对于它原有位置的偏移是基于top , 当 topauto, 该元素不移动.
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


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>
<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;}
  <div id="fix" class="pos"><p>Fixed</p></div>
  <div id="abs" class="pos"><p>Absolute</p></div>


Specification Status Comment
CSS Level 2 (Revision 1)
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.


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