包含Div不正确地当儿童Divs浮动时 [英] Containing Div Not Behaving Correctly When Child Divs are Floating

查看:94
本文介绍了包含Div不正确地当儿童Divs浮动时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题与我问过的另一个问题有关。

基本上,我有2个水平对齐的div。两个坐在一个名为.Parent的div内,因此结构如下:

Basically, I have 2 horizontally aligned divs. Both sit inside a div called ".Parent", so the structure is like this:

 <div class="Parent">
    <div style="float:right">
        <span>source list</span>
        <select size="10">
            <option />
            <option />
            <option />
        </select>
    </div>

    <div style="float:left">
        <span>dest list</span>
        <select size="10">
            <option />
            <option />
            <option />
        </select>
    </div>

    <div style="clear:both; font-size:1px;"></div>

 </div>

问题是父div存在于另一个名为#main的div中。 #main有一个白色的背景,框架所有的我的内容。

The problem is that the Parent div exists inside a another div called #main. #main has a white background that frames all of my content.

在我添加浮动到divs里面.Parent,一切都很好,因为包含Div推白色背景下降到正确的大小。但现在div是浮动的,他们不推#main的白色背景下来。

Before I added the floats to the divs inside .Parent, everything was fine because the containing Div pushed the white background down to the right size. But now that the divs are floating, they don't push #main's white background down.

任何人都可以建议如何让#main识别它的大小拉下来?

Can anyone suggest how to get the #main to recognise the size it's supposed to strech down to? Should I approach this differently?

感谢

Dave

推荐答案

提供#main overflow:hidden; 和optionall clear:both;

Give your #main overflow:hidden; and optionall clear:both;

这篇关于包含Div不正确地当儿童Divs浮动时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆