/    Sign up×
Community /Pin to ProfileBookmark

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

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@FangJun 03.2007 — 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.
Copy linkTweet thisAlerts:
@callaggaauthorJun 03.2007 — 1) A fixed height and width div would be a lot easier to work with.[/QUOTE]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?
Copy linkTweet thisAlerts:
@FangJun 03.2007 — 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.
×

Success!

Help @callagga spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...