mozilla
Your Search Results

    bottom Redirect 1

    Summary

    The bottom CSS property participates in specifying the position of positioned elements.

    For absolutely positioned elements, that is those with position: absolute or position: fixed, it specifies the distance between the bottom margin edge of the element and the bottom edge of its containing block.

    For relatively positioned elements, that is those with position: relative, it specifies the distance the element is moved above its normal position.

    However, the top property overrides the bottom property, so if top is not auto, the computed value of bottom is the negative of the computed value of top.

    • Initial value auto
    • Applies to positioned elements
    • Inherited no
    • Percentages refer to the height of the containing block
    • Media visual
    • Computed value if specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, auto
    • Animatable 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.
    • Canonical order the unique non-ambiguous order defined by the formal grammar

    Syntax

    Formal syntax: <length> | <percentage> | auto
    
    bottom: 3px         /* <length> values */
    bottom: 2.4em
    
    bottom: 10%         /* <percentages> of the height of the containing block */
    
    bottom: auto
    
    bottom: inherit
    

    Values

    <length>
    Is a negative, null or positive <length> that represents:
    • for absolutely positioned elements, the distance to the bottom edge of the containing block;
    • for relatively positioned elements, the offset that the element is moved above its position in the normal flow if it wasn't positioned.
    <percentage>
    Is a <percentage> of the containing block's height, used as described in the summary.
    auto
    Is a keyword that represents:
    • for absolutely positioned elements, the position the element based on the top property and treat height: auto as a height based on the content.
    • for relatively positioned elements, the offset the element from its original position based on the top property, or if top is also auto, do not offset it at all.
    inherit
    Is a keyword indicating that the value is the same than the computed value from its parent element (which may not be its containing block). This computed value is then handled like it was a <length>, <percentage> or the auto keyword.

    Examples

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

    The following sample page contrasts position:absolute and position:fixed. When the regular text becomes taller than the viewable portion of the page (the browser window's viewport), blocks positioned with position:absolute will scroll with the page, while blocks positioned with position:fixed will not.

    <!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) Recommendation  

    Browser compatibility

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

    See also

    Document Tags and Contributors

    Contributors to this page: Sheppy
    Last updated by: Sheppy,
    Hide Sidebar