Div Dynamic Size

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • buntyindia
    New Member
    • Jun 2007
    • 101

    Div Dynamic Size

    Hi,

    I have a Div of Height:285px used for a scrolling table.

    I want to control the size of div dynamically on the basis of record if the table has 20+ records it show full height of the div (285px) but if it have less then 20 record the size of Div decreases acordingly..... like it have 10 records the height reduced to 150px etc..


    Please help how to implement this in both browsers mozilla & IE.


    Regards,
  • realin
    Contributor
    • Feb 2007
    • 254

    #2
    Originally posted by buntyindia
    Hi,

    I have a Div of Height:285px used for a scrolling table.

    I want to control the size of div dynamically on the basis of record if the table has 20+ records it show full height of the div (285px) but if it have less then 20 record the size of Div decreases acordingly..... like it have 10 records the height reduced to 150px etc..


    Please help how to implement this in both browsers mozilla & IE.


    Regards,

    my solution may suck big time, but u can still give a try since u got no replies :p
    I am really a loser in CSS but if i were in ur boots, i would have given a pseudo height or no height to the div.. now when the records are fetched the height is automatically adjusted..

    Alternatively, you can try this tag in CSS
    [CODE=CSS]
    Overflow:scroll
    or
    overflow:auto;[/CODE]

    hope this helps u a bit atleast.

    cheers !!

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      Not overflow:auto but height:auto will work. Overflow will work but that may cause other problems later since it's used to control elements that can flow out of an element, like floated elements.

      Comment

      • buntyindia
        New Member
        • Jun 2007
        • 101

        #4
        Originally posted by drhowarddrfine
        Not overflow:auto but height:auto will work. Overflow will work but that may cause other problems later since it's used to control elements that can flow out of an element, like floated elements.
        drhowarddrfine, i have to maintain minimum height of 285px if records are more then 20. Height:auto works good for less records but when records are more then 20 it is increasing the height as well.

        How cani maintain height ?

        Comment

        • drhowarddrfine
          Recognized Expert Expert
          • Sep 2006
          • 7434

          #5
          In that case:
          {
          height:150px;
          min-height:150px;
          }

          You need both because min-height only works in modern browsers and not Internet Explorer, but IE treats height like min-height and ignores min-height. (Stupid, eh?)

          Comment

          Working...