CSS How to set div height 100% minus nPx

前端 未结 11 1359
自闭症患者
自闭症患者 2020-12-02 04:17

I have a wrapper div which contans 2 divs next to each other. Above this container I have a div that contains my header. The wrapper div must be 100% minus the height of the

11条回答
  •  旧时难觅i
    2020-12-02 05:05

    Here is a working css, tested under Firefox / IE7 / Safari / Chrome / Opera.

    * {margin:0px;padding:0px;overflow:hidden}
    div {position:absolute}
    div#header {top:0px;left:0px;right:0px;height:60px}
    div#wrapper {top:60px;left:0px;right:0px;bottom:0px;}
    div#left {top:0px;bottom:0px;left:0px;width:50%;overflow-y:auto}
    div#right {top:0px;bottom:0px;right:0px;width:50%;overflow-y:auto}
    

    "overflow-y" is not w3c-approved, but every major browser supports it. Your two divs #left and #right will display a vertical scrollbar if their content is too high.

    For this to work under IE7, you have to trigger the standards-compliant mode by adding a DOCTYPE :

    
    
    
    
    
    
    
    
    
    high content

提交回复
热议问题