0

I have 3 divs within a wrapper:

<div id="wrapper">

<div id="leftbar">
Lorem ipsum dolar sit amet
</div><!--LEFTBAR-->

<div id="middle">
Lorem ipsum dolar sit amet
</div><!--middle-->

<div id="rightbar">
Lorem ipsum dolar sit amet
</div><!--RIGHTBAR-->

</div><!--wrapper-->

Both 'leftbar' and 'middle' are floating left, whilst 'rightbar' is floating right. 'wrapper' has height:100%; clear:both; set.

However, if there is a large amount of text or content in 'middle' it overflows the 'wrapper' div. I am struggling to figure out why this is occurring.

My CSS is:

#wrapper {
    width: 1000px;
    height: 100%;
    margin:auto;
    padding: 30px;
    margin-top: 40px;
    background-color:#FFF;
    color:#000;
    border: 2px solid #828fc4;
    clear:both;
}

#leftbar {
    float:left;
    width: 150px;
    min-height: 450px;
    padding: 5px;
}

#middle {
    float:left;
    height: 100%;
    width: 580px;
    padding-left: 20px;
    padding-right: 20px;
    border-right: 1px dotted #2B308C;
    border-left: 1px dotted #2B308C;
}

#rightbar {
    float:right;
    width: 200px;
    min-height: 450px;
    padding: 5px;
}

Any advice is appreciated!

MeltingDog
  • 14,310
  • 43
  • 165
  • 295

5 Answers5

2

Add overflow:auto to #textcontent and remove height:100% form #textcontent and #maincontent

Musa
  • 96,336
  • 17
  • 118
  • 137
1

As you edited your question, I just came to know how it was overflowing, it is because you are using height: 100%;, so your div wont exceed the viewport, so use height: auto; instead and also use overflow: auto; for #textcontent instead of clear: both; as Musa told you to do..(Checked with firebug)

Mr. Alien
  • 153,751
  • 34
  • 298
  • 278
1

This is the css file with some minor additions:

  • Text-align for your bar's
  • Width in the wrapper was set to 1000px so all the px were distributed equally among the bar's.
#wrapper {
width: 1000px;
height: auto;
margin:auto;
padding: 30px;
margin-top: 40px;
background-color:#FFF;
color:#000;
border: 2px solid #828fc4;
clear:both;
overflow:auto;
}
#leftbar {
float:left;
width: 250px;
padding: 5px;
text-align:center;
}

#middle {
float:left;
width: 400px;
padding-left: 20px;
padding-right: 20px;
border-right: 1px dotted #2B308C;
border-left: 1px dotted #2B308C;
text-align: center;
}

#rightbar {
float:right;
width: 250px;
padding: 5px;
text-align:center;
}

Just my two cents

Paul
  • 142
  • 2
  • 2
  • 12
0

If you need that for text only, try using CSS3 column.

Nutic
  • 1,407
  • 4
  • 16
  • 31
0

Add overflow property and change height to auto.

#wrapper {
    width: 1000px;
    height: auto;
    margin:auto;
    padding: 30px;
    margin-top: 40px;
    background-color:#FFF;
    color:#000;
    border: 2px solid #828fc4;
    clear:both;
    overflow:hidden;
}
#middle {
    float:left;
    width: 580px;
    padding-left: 20px;
    padding-right: 20px;
    border-right: 1px dotted #2B308C;
    border-left: 1px dotted #2B308C;
}