/    Sign up×
Community /Pin to ProfileBookmark

Fixed size div

I am trying to create a div element with fixed size in html. My problem is, the above div receives input text from javascript. The size of text is unknown, so every time that the transmitted text is big, automatically the size of the div is change. How is it possible to display only the first words of the text that fit in the predefined size of the div???

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@rootOct 29.2013 — Us CSS to set the DIV size and also font and texts size defaults.
Copy linkTweet thisAlerts:
@zenitisauthorOct 29.2013 — The problem is that the font size and text size constantly changes. An effect that i want to keep. I define default size, for my div element. Nevertheless, every time that the text is big, it change the div size. I want to display only the text that fits in div, whichever the size of text and font are.
Copy linkTweet thisAlerts:
@PadonakOct 30.2013 — maybe overflow:hidden will help?
Copy linkTweet thisAlerts:
@rootOct 30.2013 — div#setsize{max-height:xxpx; max-width:xxpx; overflow:scroll;}

where setsize is the id of the div you are attacking with this CSS, the xxpx is the size in pixels, eg..

div#setsize{max-height:400px; max-width:300px; overflow:scroll;}

so as soon as your content gets larger than the 400px height limitation, your overflow should scroll.

You would need to work on the scroll bars, the only option I see that you have is to scale the DIV content so it fits and is still maintaining some flavor of your original content.
Copy linkTweet thisAlerts:
@zenitisauthorOct 31.2013 — Yea i got it, thanks guys!!
×

Success!

Help @zenitis 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.15,
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,
)...