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

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

I have a site with the following structure:

<
相关标签:
26条回答
  • 2020-11-22 07:42

    Add display: grid to the parent

    0 讨论(0)
  • 2020-11-22 07:43

    I find that setting the two columns to display: table-cell; instead of float: left; works well.

    0 讨论(0)
  • 2020-11-22 07:43
    .row-eq-height {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display:         flex;
     }
    

    From:

    http://getbootstrap.com.vn/examples/equal-height-columns/equal-height-columns.css

    states bootstrap but you do not need bootstrap to use this. Answering this old question, as this worked for me, and seems pretty easy to implement.

    This was the same answer I provided to this Question

    0 讨论(0)
  • 2020-11-22 07:45

    Try making the bottom margin 100%.

    margin-bottom: 100%;
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-11-22 07:47

    [Referring to Dmity's Less code in another answer] I'm guessing that this is some kind of "pseudo-code"?

    From what I understand try using the faux-columns technique that should do the trick.

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

    Hope this helps :)

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