Connecting Tech Pros Worldwide Forums | Help | Site Map

Containing div not containing

Newbie
 
Join Date: Jun 2007
Posts: 26
#1: Oct 4 '09
I have a large div and am trying to place 4 divs inside it. The containing div has a set height, as do two of the contained div. The other two do not have set heights.

It works fine unless one of the divs without a set height gets too big. If that happens, I want it to add a scroll bar. Instead, it just cuts off the rest of the content.

Here are my divs:

Containing Div:
Expand|Select|Wrap|Line Numbers
  1. #CenterDivNA {
  2.     width: 580px;
  3.     height: 800px;
  4.     float: left;
  5.     background: #FFFFFF;
  6.     display:block;
  7. }
  8.  
This set-height div is repeated twice:
Expand|Select|Wrap|Line Numbers
  1. #DishClassNA {
  2.     position: relative;
  3.     border-top: 1px solid #666666;
  4.     border-bottom: 1px solid #666666;
  5.     text-align: left;
  6.     height: 20px;
  7. }
  8.  
Here is the (usually) shorter of the two variable height divs:
Expand|Select|Wrap|Line Numbers
  1. TopFrameCenterTable {
  2.     position: relative;
  3.     text-align: left;
  4. }
  5.  
And here is the other one:
Expand|Select|Wrap|Line Numbers
  1. #centerframena{
  2.     position: relative;
  3.     text-align: left;
  4.     overflow:auto;
  5.     padding-left: 15px;
  6.     width: 564px;
  7. }
  8.  
Thanks for all ideas.

drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,573
#2: Oct 4 '09

re: Containing div not containing


You can't use the same id name for more than one element.

To get the scroll bars, add 'overflow:scroll' to the parent. (not tested)
Newbie
 
Join Date: Jun 2007
Posts: 26
#3: Oct 5 '09

re: Containing div not containing


Thanks - You're right on the double ID's, it's actually a class, sorry, I showed it wrong.

Adding "overflow: scroll;" to the parent does add a scroll bar to the whole containing div, all the time. (Adding "overflow: auto;" to the parent adds a scroll bar to the whole containing div when necessary.)

I want a scroll bar on ONLY the last div, the "centerframena" div, ONLY when necessary.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,573
#4: Oct 5 '09

re: Containing div not containing


Can you construct a sample page cause I'm too lazy to do it myself.
Newbie
 
Join Date: Jun 2007
Posts: 26
#5: Oct 6 '09

re: Containing div not containing


Yes, here is an example page:

http://www.dinnerbeat.com/Example.asp

I added colors to the different divs so it is easier to see.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,573
#6: Oct 6 '09

re: Containing div not containing


If you add 'overflow:scroll' to CenterDivNA, you get the scroll bars but for the whole center div and not just centerframena but it's close. That's because it's overflowing it's parent. centerframena does not have a similar parent to overflow and that's why just adding overflow:scroll to it does not do what you want.

The solution might lie in creating a wrapper around the actual contents but still giving centerframena the overflow:auto property which will create the scrollbars when needed. This way, when the contents overflow centerframena, you'll get the scroll bars.
Reply

Tags
css containers