How-to mix fixed and percentage heights/width using css without javascript

前端 未结 2 1310
天命终不由人
天命终不由人 2021-01-01 02:18

I want to achieve a layout like this:

 -----------------------------------------------------------
|                                                                 


        
相关标签:
2条回答
  • 2021-01-01 02:41

    See: http://jsfiddle.net/s7FH6/show/ (edit)

    HTML:

    <div id="header"></div>
    <div id="content"></div>
    

    CSS:

    html, body {
        margin: 0;
        padding: 0;
        overflow: hidden
    }
    #header {
        background: #ccc;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 150px
    }
    #content {
        background: #eee;
        position: absolute;
        left: 0;
        top: 150px;
        bottom: 0;
        width: 100%;
        overflow-y: scroll
    }
    
    0 讨论(0)
  • 2021-01-01 02:42

    you can achieve layout like that very simple to be honest just read about divs and some css heres a example:

    <div style="width: 604px; height: 405px; border: solid 1px black;">
    <div style="width: 100%; height: 100px; border: solid 1px green;"></div>
    <div style="width: 100%; height: 74%; border: solid 1px blue;"></div>
    </div>
    

    dont forget that the width: 604px is only for example just set it to 100% to use all screen size same goes for height.

    good luck.

    example: http://jsfiddle.net/DCbur/2/

    dont forget to vote if you like the answer

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