Connecting Tech Pros Worldwide Forums | Help | Site Map

need a div to grow automatically as the table inside it

Newbie
 
Join Date: Feb 2009
Posts: 8
#1: May 5 '09
Hi guys,

i only know basic css mainly the formatting part....

i want to create a side panel for my website that looks like a small window that has a blue header and blue borders and slightly curved bottam border...i did this by making images and setting them as backbround images fo the respective divs

here my code

Expand|Select|Wrap|Line Numbers
  1.  <div id="docket">
  2.             <div id="header">
  3.             </div>
  4.             <div id="left">
  5.             </div>
  6.             <div id="middle">
  7.             </div>
  8.             <div id="right">
  9.             </div>
  10.             <div id="bottam">
  11.             </div>
  12.         </div>
  13.  
and in the css i have defined these

Expand|Select|Wrap|Line Numbers
  1. #docket
  2. {
  3.     width:189px;
  4.     height:auto;
  5. }
  6. #header
  7. {
  8.     width:100%;
  9.     background:url(images/STRIP01.jpg) no-repeat;
  10.     height:24px;
  11.  
  12. }
  13. #left
  14. {
  15.     float:left;
  16.     width:1%;
  17.     background:url(images/STRIP0W2.jpg) no-repeat;
  18.     height:80px;
  19.  
  20.  
  21. }
  22. #middle
  23. {
  24.     float:left;
  25.     width:98%;
  26.     background:url(images/popBG.jpg);
  27.     height:80px;
  28. }
  29. #right
  30. {
  31.     float:left;
  32.     width:1%;
  33.     background:url(images/STRIP0W2.jpg) no-repeat;
  34.     height:80px;
  35. }
  36. #bottam
  37. {
  38. clear:both;
  39. width:100%;
  40. background:url(images/STRIP0W3.jpg) no-repeat;
  41. height:7px;
  42. }
  43.  
in the main div i will place a table that has say 6 or 7 rows with various options for the user such as profile visit,messsages,videos,pics etc...now sometimes i want to show or hide some rows based on privacy settings and i want it to resize automatically......

i an earlier post i learnt that float overflows its container but the rest was pretty cryptic to me.....tried using auto but that diidnt work

you will notice that the left,main,and right have fixed widths of 80px to incorporate six rows...so is there any way to do this???

it works pretty well except the fact that it doesnt resize automatically

Member
 
Join Date: Aug 2007
Location: Pakistan
Posts: 91
#2: May 5 '09

re: need a div to grow automatically as the table inside it


Place your table inside the div tag having id=middle and change the height and width to 100%

Expand|Select|Wrap|Line Numbers
  1. <div id="docket"> 
  2.             <div id="header"> 
  3.             </div> 
  4.             <div id="left"> 
  5.             </div> 
  6.             <div id="middle">
  7. <table><tr><td>&nbsp;</td></tr></table> 
  8.             </div> 
  9.             <div id="right"> 
  10.             </div> 
  11.             <div id="bottam"> 
  12.             </div> 
  13.         </div> 
  14.  
Newbie
 
Join Date: Feb 2009
Posts: 8
#3: May 5 '09

re: need a div to grow automatically as the table inside it


thanks for replying....

already treid that...it does cause the div to expand as neccessay...but then the left and right lines disapper and dont show...and all i get is a box with the header and the content and the bottam....no side images....which i think means that the left and right div are being over riden.

they only have a width of 1%

plz can anyone tell me how to do it
Member
 
Join Date: Aug 2007
Location: Pakistan
Posts: 91
#4: May 5 '09

re: need a div to grow automatically as the table inside it


why don't you use table instead of divs.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#5: May 7 '09

re: need a div to grow automatically as the table inside it


...because tables shouldn't be used for layout.
Reply