Dave
Dave

Reputation: 8461

CSS - float causing undesired render

My CSS:

body
{
    font-family:verdana;
    line-height:1.5em;
    color:#666;
    font-size:0.8em;
}

.objectAttributesOuter
{
    border: 1px solid #999;
    padding:6px;
    margin:6px;
    background-color:#EDEEFA
}


.objectAttributes
{
    padding: 5px, 0px, 5px, 5px;
}


.whiteBoxWithBorder
{
    padding:5px;
    margin-right:5px;
    background-color:#fff;    
    border: solid 1px #ccc;
    float:left;
}

My HTML:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
<Title>Details</Title>
<link rel  = "stylesheet" href="css.css" type = "text/css" />
</HEAD>
<BODY>


<div class = "objectAttributesOuter">
    <div class="objectAttributes">
         <div class="whiteBoxWithBorder">
                GetType()
         </div> 
         <div class="whiteBoxWithBorder">
                Returns the type ...
         </div>
    </div>
</div>


</BODY>
</HTML>

The ideal render would be to have the "whiteBox" rendered inside the "objectAttributesOuter" but as you can see it overlaps. If I remove the float tag, then the 2 divs render inside the whiteBox but, do not display side by side.

Any ideas how I can have them display side by side within the "objectAttributesOuter" tag?

Upvotes: 1

Views: 965

Answers (4)

Random Guy
Random Guy

Reputation: 2900

Check this out myFiddle

Use <div style="clear:both"></div>

Upvotes: 2

Narendra
Narendra

Reputation: 3117

Change objectAttributesOuter class as follow;

.objectAttributesOuter
{
    border: 1px solid #999;
    padding:6px;
    margin:6px;
    background-color:#EDEEFA;
    overflow:auto;
}

Upvotes: 0

Lowkase
Lowkase

Reputation: 5699

Put a float:left on objectAttributesOuter:

.objectAttributesOuter
{
    border: 1px solid #999;
    padding:6px;
    margin:6px;
    background-color:#EDEEFA;
    float:left;
}

Upvotes: 0

Billy Moat
Billy Moat

Reputation: 21050

Try putting overflow:auto on .objectAttributes and see if that helps.

It would also help if you had widths on your container and the floating elements.

Upvotes: 0

Related Questions