How to force child div to be 100% of parent div's height without specifying parent's height?

前端 未结 26 1992
刺人心
刺人心 2020-11-22 06:52

I have a site with the following structure:

<
26条回答
  •  無奈伤痛
    2020-11-22 07:47

    If you don't mind the navigation div being clipped in the event of an unexpectedly-short content div, there's at least one easy way:

    #main {
    position: relative;
    }
    
    #main #navigation {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 10em; /* or whatever */
    }
    
    #main #content {
    margin: 0;
    margin-left: 10em; /* or whatever width you set for #navigation */
    }
    

    Elsewise there's the faux-columns technique.

提交回复
热议问题