Page 1 of 1

Most intelligent way to control content height

Posted: Fri Mar 14, 2008 6:08 am
by KalleL
Hi,

At first I want to apologise if this content is in wrong section, as this matter concerns php, html and javascript, so i'm not sure where to put this. But, let's get to point.

We've been designing web page that has nice picture background, but we've run into little problem. As I mentioned, we have background image which is 1600x1200 (filesize optimized) but it can't be made any bigger than that. The height of this picture is a problem when page holds a lot of text, for example in news pages. Now we're thinking of ways to split the content of page (with read more -links or so). The div that holds the text has fixed width of 322px. Defining the limit for page size is quite hard with characters, as different words make linebreaks to different positions in text. Also user might user bigger/smaller font with their browser and that also changes the space the content needs. Now i'm wondering if there's way to get height of div, using javascript for example? Then we could code javascript buttons with css display -options to show the content in parts. Or is there any other way to do this? I know PHP's capabilities to count characters, and one way to solve this would be use loops, character counter functions and functions to parse spaces between words in texts to add the <br /> tags, but I don't find this very neat way to do this.

Is there any shortcuts to do this?

Regards,

Kalle Laakso

Re: Most intelligent way to control content height

Posted: Fri Mar 14, 2008 6:50 am
by onion2k
Fix the height of the div the content is in using height: 1200px in CSS, then add overflow: auto; to make it scroll if there's too much content to fit. If the user changes the the font size in their browser it'll continue to work. That's the most sensible approach. It will stick a scrollbar in the middle of your site though.

Otherwise the most sensible approach is to be careful when you're adding content. Check it prior to it being put live and optimise it by hand. Not everything can be solved well through coding.