mozilla
您的搜索结果

    text-align

    Summary

    The text-align CSS property describes how inline content like text is aligned in its parent block element. text-align does not control the alignment of block elements itself, only their inline content.

    • <dfn style=" display:table-cell; padding: 0 5px; border-bottom: none; cursor:inherit;">初始值:</dfn> a nameless value that acts as left if 'direction' is 'ltr', right if 'direction' is 'rtl'
    • <dfn style=" display:table-cell; padding: 0 5px; border-bottom: none; cursor:inherit;">Applies to:</dfn> block level elements, table cells and inline-blocks
    • <dfn style=" display:table-cell; padding: 0 5px; border-bottom: none; cursor:inherit;">可继承:</dfn> yes
    • <dfn style=" display:table-cell; padding: 0 5px; border-bottom: none; cursor:inherit;">Media:</dfn> visual
    • <dfn style=" display:table-cell; padding: 0 5px; border-bottom: none; cursor:inherit;">计算值:</dfn> as specified

    Syntax

     text-align:  left | center | right | justify | start | end | -moz-left | -moz-center | -moz-right | inherit
    

    Values

    left
    The inline contents are aligned to the left edge of the line box.
    right
    The inline contents are aligned to the right edge of the line box.
    center
    The inline contents are centered within the line box.
    justify
    The text is justified. Text should line up their left and right edges to the left and right content edges of the paragraph.
    start
    The same as left if direction is left-to-right and right if direction is right-to-left.
    end
    The same as right if direction is left-to-right and left if direction is right-to-left.

    Mozilla Extensions

    -moz-center
    Centers inline and also block content.
    -moz-left
    Aligns inline and also block content.
    -moz-right
    Aligns inline and also block content.

    Examples

    查看在线演示

    Live Examples

    div { text-align: center; border:solid; }

    p { background:gold; width:22em; }

    some more inline content...
    div { text-align: center; border:solid; }

    p { background:gold; width:22em; margin: 1em auto; }

    some more inline content...
    div { text-align:-moz-center; text-align:-webkit-center; border:solid; }

    p { background:gold; width:22em; }

    some more inline content...

    Notes

    The standard-compatible way to center a block itself without centering its inline content is setting the left and right margin to auto, e.g.:
    margin:auto;  or  margin:0 auto;  or  margin-left:auto; margin-right:auto;

    Browser compatibility

    Browser Basic support Block alignment values start value end value
    Internet Explorer 3.0 --- --- ---
    Firefox (Gecko) 1.0 (1.0) 1.0 (1.0) -moz-left | -moz-center | -moz-right 1.0 (1.0) 3.6 (1.9.2)
    Opera 3.5 --- --- ---
    Safari (WebKit) 1.0 (85) 1.0 (85) -khtml-left | -khtml-center | -khtml-right 3.1 (525) 3.1 (525)
    1.3 (312) -khtml-left | -khtml-center | -khtml-right |
    -webkit-left | -webkit-center | -webkit-right

    Specifications

    See also

    margin:auto, margin-left:auto, vertical-align

    文档标签和贡献者

    此页面的贡献者有: ziyunfei
    最后编辑者: ziyunfei,