msinfo
msinfo

Reputation: 1175

CSS div border around child divs

  1. I have one container div, which contains 3 divs inside it.
  2. When i write border:1px solid red for container div, border is shown only on top of these 3 child divs, but not around them.
  3. Below is css code.

    #cont {
        width:800px;
        margin-right:auto;
        margin-left:auto; 
        border:1px dashed red;
        padding:2px;
    }
    #third, #second, #first {
        width:260px;
        float:left;
        margin:2px;
    }
    

Html code:

![<div id="cont">
<div id="third"><p>A demo text </p></br>
<p>A demo text </p></br>
<p>A demo text </p></br>
<p>A demo text </p></br>
</div>

<div id="second"><p>A demo text </p></br>
<p>A demo text </p></br>
<p>A demo text </p></br>
<p>A demo text </p></br>
</div>

<div id="third"><p>A demo text </p></br>
<p>A demo text </p></br>
<p>A demo text </p></br>
<p>A demo text </p></br>
</div>
</div>][1]

Upvotes: 2

Views: 7493

Answers (3)

Adam
Adam

Reputation: 623

add overflow:hidden to the #cont element

Upvotes: 0

syrkull
syrkull

Reputation: 2344

<div style="clear:both;float:none;"></div> well solve your problem. added it under the div's

Upvotes: 0

jikey
jikey

Reputation: 394

add overflow:hidden;

#cont {width:800px;margin-right:auto;margin-left:auto; border:1px dashed red;padding:2px; overflow:hidden;}

Upvotes: 4

Related Questions