www.webdeveloper.com
Results 1 to 4 of 4

Thread: constraining Text/Content in a DIV area that can vary in size ????

  1. #1
    Join Date
    Dec 2006
    Posts
    25

    Question constraining Text/Content in a DIV area that can vary in size ????

    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

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    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.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Dec 2006
    Posts
    25
    Quote Originally Posted by Fang
    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?

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    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.
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles