Child div 100% height to parent auto height

后端 未结 7 886
忘了有多久
忘了有多久 2021-02-12 19:47

Im here because other similar questions couldn\'t help my particular problem.

I need right div to be 100% height all the time, where the parent

相关标签:
7条回答
  • 2021-02-12 20:26

    Give position:fixed and height:100% for the right div. This will solve your issue.

    0 讨论(0)
  • 2021-02-12 20:30

    Try by giving the height of container a fixed value

    this will also fix the issue. Just tried it in jsFiddle

    http://jsfiddle.net/C9Kmx/35/

    .container
    {
        min-height: 10px;
        width: auto;
        height: 100px;
        background-color: #eeeeee;
    }
    
    0 讨论(0)
  • 2021-02-12 20:32

    By reading your comments on other solutions it is clear to me that only solution for you is to implement some JS into your code. This is not a problem, however.

    http://jsfiddle.net/b7TuP/

    0 讨论(0)
  • 2021-02-12 20:34

    Make the right div position:absolute; and make the parent div position:relative; and then height:100%; will work for the right div. Make sure you also adjust its x-position and width accordingly. In this example I gave it a left:50px to make sure it appears to the right of the left column.

    JSFiddle http://jsfiddle.net/e9mvD/

    0 讨论(0)
  • 2021-02-12 20:49

    .parent{
        position: relative;
        width: 100px;
        height: auto;
    }
    .child{
        width: 50px;
        height: 100px;
        background-color: red;
    }
    .child_absolute{
        position: absolute;
        left: 50px;
        top: 0;
        bottom: 0;
        width: 50px;
        background-color: blue;
    }
    <div class="parent">
        <div class="child"></div>
        <div class="child_absolute"></div>
    </div>

    0 讨论(0)
  • 2021-02-12 20:51

    You can use the table-cell value of the display property in this layout and remove the float like this:

    .left, .right{
        display:table-cell;
    }
    

    live demo http://jsfiddle.net/C9Kmx/34/

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