Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

580 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