views:

41

answers:

2

So, basically if a div reaches 50px I want to, then, turn on the scroll bar (vertcially). Any JQuery Ideas would be nice.

+4  A: 

You can do that in CSS, though max-height may require hacks for IE.

div {
    max-height: 50px;
    clip: auto;
    overflow: auto;
}

If you have a specific jQuery use, you would need to share a little code.

patrick dw
better answer than mine. I was thinking jquery.
aepheus
Works from IE7 up, good to go.
Douglas
@aepheus - Well, jQuery could be an appropriate solution too, depending on the situation. Might be easier than messing with IE CSS fixes.
patrick dw
@Douglas - Thanks for the note. Wasn't sure about IE7.
patrick dw
+1  A: 

When adding content to the div, check $('#something').height(). If it exceeds 50, set height to 50, and add scroll bars, otherwise leave it alone.

$('#something').css('height','50px').css('overflow','auto');

aepheus