简体   繁体   English

div不会扩展到100%的宽度(在另一个div中彼此重叠)

[英]Divs won't expand to 100% width (on top of each other within another div)

I have a header that is divided into a few parts. 我有一个标题,分为几个部分。

First, it's divided into left, and right. 首先,它分为左和右。

The right part is then divided into stacked top and bottom, or at least that's what I'm trying to do. 然后将右侧部分分为顶部和底部堆叠,或者至少这是我要尝试的操作。

However, they won't show up (unless there's text or something.) 但是,它们不会显示(除非有文字或其他内容。)

HTML 的HTML

<div id="header">
    <div id="header_left">
        <div id="header_title">
            <p id="t1">TEXT</p>
            <p id="t2">TEXT</p>
            <p id="t3">TEXT</p>
        </div>
    </div>
    <div id="header_right">
        <div id="right_top">x</div>
        <div id="right_bottom">x</div>
    </div>
</div>

CSS 的CSS

    #header_right {
    height:100%;
    float:right;
}

#right_top {
    height:140px;
    width:100%;
    display:block;
    background-color:#FF0000;
}

#right_bottom {
    height:60px;
    width:100%;
    display:block;
    background-color:#000;
}

您必须设置position:absolute以显示空div

position:absolute;

You should to add this: 您应该添加以下内容:

#header_right {
    height:100%;
    float:left;  /*changed from right*/
}

/*added new class*/
#header_left{
    float: left;
    width: 97%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM