开发者

height of div equals to "0"

开发者 https://www.devze.com 2023-01-24 22:37 出处:网络
I have a very si开发者_运维技巧mple html code: <body> <div id=\"container\"> <div id=\"left\">

I have a very si开发者_运维技巧mple html code:

<body>
        <div id="container">
            <div id="left">
                some text here
            </div>
            <div id="right">
                and some text here
            </div>
        </div>
    </body>

and styles:

div#left {
    float: left;
    background: #e2e2e2;
}

div#right {
    float: right;
    background: #1469ab;
}

I want to have the height of div #container equal to heights of it's content, but now it actually 0. How to implement this behavior?


you should apply a non-structural clearing to the container like easyclearing http://www.positioniseverything.net/easyclearing.html

otherwise you can also specify height: auto; overflow: hidden to the container


add overflow:auto to your #container

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号