CSS: fix the height of a section within a variable height element

后端 未结 2 1117
轻奢々
轻奢々 2021-01-25 11:10

Related to this question.

Here\'s a fiddle: http://jsfiddle.net/DRbRS/

Notice how the red-outlined list div does not align at the bottom of the green container

相关标签:
2条回答
  • 2021-01-25 11:44

    Using position: absolute and setting top, left, right, and bottom: http://jsfiddle.net/QARC9/

    This article describes why it works.

    http://www.alistapart.com/articles/conflictingabsolutepositions/

    0 讨论(0)
  • 2021-01-25 12:02

    Replace your CSS with this

    #container {
    
        left: 50px;
        width: 200px;
        position: fixed;
        height: 90%;
        border: 2px dashed green;
    }
    
    
    #header {
        height: 30px;
        line-height: 30px;
        text-align: center;    
        border: 2px dashed blue;
        margin-left:-2px;
        margin-top:-2px;
        width:200px
    }
    
    #list {    
        border: 2px dashed red;
        overflow: auto;
        height: 91%;
        width:200px;
        margin-left:-2px;
        margin-top:-2px;
    
    
    }​
    

    or see the demo here http://jsfiddle.net/enve/DRbRS/3/

    0 讨论(0)
提交回复
热议问题