DIV height overflow problem

Posted on 2003-03-12
Medium Priority
Last Modified: 2008-01-16
I have a DIV that currently looks like this:
<div style="width: 500px; height: 200px; overflow: hidden;"><!-- content --></div>

which is repeated throughout the page.  

If the content is larger then 200 pixels, it clips it, which is fine. The problem is that if the content is smaller, theres a large gap.  Is there a more elegant way to eliminate the gap than writing each div dynamically using javascript?

Question by:gxmikey
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 14

Accepted Solution

avner earned 200 total points
ID: 8125497
Yuo can do that for IE only, this way :
<div style="border:1px solid black;width: 500px; height: expression((parseInt(this.scrollHeight)>200)?200:this.scrollHeight);overflow: hidden;">

This way the dic height will be the size of the content or, maximum of 200px.


Author Comment

ID: 8125888
works wonderfully in mozilla, ie 5.5+ net6+ and phoenix, all i need. Thanks!!!

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question