0

i have a div and its height is fixed to 100px right now.

but its data is not static and a user can add as much data as he wants, i dont want scroll bars and it should get resized to data contained in it(height only) is there any css property to achieve this except than min-height as it doesnot work on IE.

the div may have multiple children and i am thinking to do something that doesnt involve calculating change of height of all children

thanks

3
  • do you need to mention a minimum height if there is nothing in the div? Commented May 23, 2011 at 7:19
  • @sv_in - yes minimum is required Commented May 23, 2011 at 7:31
  • read this and this one Commented May 23, 2011 at 7:46

5 Answers 5

1

height in IE6 is essentially min-height anyway. If you don't have a problem using quick hacks -

div.blah {
    _height:100px;
    min-height:100px;
}

...otherwise, tuck it in some Conditional Comments so you can sleep at night.

<!--[if IE 6]>
    <style type="text/css">div.blah { height:100px; }</style>
<![endif]-->
Sign up to request clarification or add additional context in comments.

3 Comments

@Varun, The first property _height works only IE6 where height property works like min-height. For other browsers, min-height is the way to go
so its back to basic i have to perform JS actions on IE then, which dont want
@Varun: There's no JS in my answer, only a minor CSS hack for IE6.
0

You can specify height:auto;overflow:visible;. This will make the <div> autosize itself.

1 Comment

cant give height as auto, need some predefined structure
0
overflow:visible; height:100px;

Should work, no?

1 Comment

will result in overlapping with other parts of page
0

Check out this plugin: http://james.padolsey.com/javascript/jquery-plugin-autoresize/

Hope I helped.

Comments

0

had to do using jQuery only calculated height of children and set it parent, css hacks dint helped

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.