Home  >  Q&A  >  body text

javascript - The child div is float; how to make the height of the child div inherit the height of the parent

The p of the child is float; how to make the height of the p of the child inherit the height of the parent

淡淡烟草味淡淡烟草味2662 days ago1113

reply all(5)I'll reply

  • 阿神

    阿神2017-07-05 11:09:01

    You are talking about clearing the float, just set overflow:hidden; on the parent level

    reply
    0
  • PHP中文网

    PHP中文网2017-07-05 11:09:01

    The amount of information in the question is relatively small. I don’t know if this is the effect you want:

    HTML:

    <p class="parent-p">
        <p class="child-p"></p>
        <p class="child-p"></p>
        <p class="child-p"></p>
    </p>

    CSS:

    .parent-p {
        position:relative;
        height: 400px;
        width: 200px;
        background-color:forestgreen;
    }
    
    .child-p {
        float:left;
        margin-left:10px;
        width: 53px;
        height: inherit;
        background-color: tomato;
    }
    }

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-07-05 11:09:01

    Give the height of the parent element and then set height:100% for the child element?

    reply
    0
  • 習慣沉默

    習慣沉默2017-07-05 11:09:01

    100% No problem

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-07-05 11:09:01

    Baidu clearly floats, there are a lot of methods

    reply
    0
  • Cancelreply