# How to dynamically constrain amount of Text/Content in a DIV

**URL:** <https://www.ruby-forum.com/t/how-to-dynamically-constrain-amount-of-text-content-in-a-div/105455>\
**Category:** Rails\
**Created:** [May 30, 2007, 5:33am UTC](https://www.ruby-forum.com/t/how-to-dynamically-constrain-amount-of-text-content-in-a-div/105455 "2007-05-30T05:33:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [May 30, 2007, 5:33am UTC](https://www.ruby-forum.com/t/how-to-dynamically-constrain-amount-of-text-content-in-a-div/105455/1 "2007-05-30T05:33:16Z")

</div>

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 in Rails? 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) 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?

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
