CSS - Making a div consume all available space

后端 未结 3 616
臣服心动
臣服心动 2020-12-10 02:25

All,

I have a page which is suppose to take up only the available screen space in the browser.

I have a \'top bar\' and a \'bottom bar\', both of which are f

3条回答
  •  情歌与酒
    2020-12-10 03:28

    You can use relative and absolute positions. Here an example:

    css

       html,body,#wrapper {
            height:100%;
            margin:0;
            padding:0;
        }
        #wrapper {
            position:relative;
        }
    
        #top, #middle, #bottom {
            position:absolute;
        }
    
        #top {
            height:50px;
            width:100%;
            background:grey;
        }
        #middle {
            top:50px;
            bottom:50px;
            width:100%;
            background:black;
        }
        #bottom {
            bottom:0;
            height:50px;
            width:100%;
            background:grey;
        }
    

    html

    Demo: http://jsfiddle.net/jz4rb/4

提交回复
热议问题