height: auto;   与不写height 有什么区别啊

解决方案 »

  1.   

    参考一下这里
    http://blog.csdn.net/firegun17/archive/2009/05/08/4161565.aspx
      

  2.   

    默认情况下,表格的宽度和高度根据内容自动调整
    通过WIDTH属性定义表格的宽度,HEIGHT属性定义表格的高度,单位是像素或百分比。如果是百分比,则可分为两种情况:如果不是嵌套表格,那么百分比是相对于浏览器窗口而言;如果是嵌套表格,则百分比相对的是嵌套表格所在的单元格宽度。
      

  3.   

    The property is read/write with a default value of auto; the CSS attribute is not inheritedIf an auto-height, block-level, normal-flow element has only block-level children, then its default height will be the distance from the top of the topmost block-level child's outer border edge to the bottom of the bottommost block-level child's outer border edge. Therefore, the margins of the child elements will "stick out" of the element that contains them. (This behavior is explained in the next section.) However, if the block-level element has either top or bottom padding, or top or bottom borders, then its height will be the distance from the top of the outer top margin edge of its topmost child to the outer bottom margin edge of its bottommost child
    <div style="height: auto; background: silver;">
    <p style="margin-top: 2em; margin-bottom: 2em;">A paragraph!</p>
    </div>
    <div style="height: auto; border-top: 1px solid; border-bottom: 1px solid;
    background: silver;">
    <p style="margin-top: 2em; margin-bottom: 2em;">Another paragraph!</p>
    </div>