Click to See Complete Forum and Search --> : constraining Text/Content in a DIV area that can vary in size ????


callagga
06-03-2007, 05:56 AM
Hi,

Can anyone recommend how best to how to dynamically constrain amount of Text/Content in a DIV area that can vary in size??

That is, say you have:
(a) a content (DIV) area on your view that can expand/contract depending upon browser size ( i.e. when someone is re-sizing the browser window) and
(b) dynamic text/content that is to be displayed, based upon user input - e.g. image a defined area/size for several user comments for example. Users can create their own comments, but you only want them to be able to take up a given amount of screen resource, and then perhaps have a "...more" link at the bottom if they go over.

How can I best setup this up? e.g.
(1) How to setup the layout/CSS so that if more text / content is present in the DIV area that can be displayed that the DIV area doesn't expand due to the extra content the user put forward, and/or
(2) Do I need to also complete this by programming what content comes out? E.g. in Ruby on Rails say then the question would be how to calculate how much text/content can fit in the current size of the DIV (noting browser re-sizing) so that you get the chance to put the "...more" link at the bottom? Hopefully this approach isn't required.

Any other suggestions welcome that address what I'm trying to do are welcome, which is really offering a area for display of user feedback where each piece of feedback has a maximum area it can take on the main screen only, and also that browser re-sizing is possible.

Tks
Greg

Fang
06-03-2007, 12:29 PM
1) percentage width and a fixed height

2) JavaScript to add "...more" link if required and polling of onresize.

A fixed height and width div would be a lot easier to work with.

callagga
06-03-2007, 02:18 PM
1) A fixed height and width div would be a lot easier to work with.This would be OK in my case, but the question would still remain wouldn't it to determine (in the javascript) at what point to cut the content and add in the "..more.." link no?

Fang
06-03-2007, 03:37 PM
Preferably server-side. Cut the comment to a maximum length that would fit the div. Remove the end characters back to a space character, add the link and add it to the div.