Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
475 views
in Technique[技术] by (71.8m points)

html - CSS - 将float子DIV高度展开为父级的高度(CSS - Expand float child DIV height to parent's height)

I have the page structure as:

(我的页面结构如下:)

<div class="parent">
    <div class="child-left floatLeft">
    </div>

    <div class="child-right floatLeft">
    </div>
</div>

Now, the child-left DIV will have more content, so the parent DIV's height increases as per the child DIV.

(现在, child-left DIV将有更多内容,因此parent DIV的高度根据孩子DIV增加。)

But the problem is child-right height is not increasing.

(但问题是child-right身高不会增加。)

How can I make its height as equal to it's parent?

(我怎样才能使它的高度等于它的父母?)

  ask by Veera translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For the parent element, add the following properties:

(对于parent元素,添加以下属性:)

.parent {
    overflow: hidden;
    position: relative;
    width: 100%;
}

then for .child-right these:

(然后为.child-right这些:)

.child-right {
    background:green;
    height: 100%;
    width: 50%;
    position: absolute;
    right: 0;
    top: 0;
}

Find more detailed results with CSS examples here and more information about equal height columns here .

(找到CSS的例子更详细的结果这里约等于身高列的详细信息在这里 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...