1

I have a <div> block that contains an unknown amount of text.

The css for the block is:

.synopsis { width:600px; height:32px; line-height:16px; overflow:hidden; }

In essence the block allows for two lines of text, once the text reaches the block's limits, the rest is hidden from view.

What is the cleanest method to find out what text has been hidden from view? Any jQuery/Javascript functionality that does this?

2
  • When you say you want to find out what text is hidden, do you mean as a substring of the original full text (ie. as a Javascript string)? Commented Feb 8, 2012 at 16:04
  • Yes, that is exactly what I need... The text that isn't displayed in the view... I need it as a string.. C#, Javascript.. whatever Commented Feb 8, 2012 at 16:21

3 Answers 3

0

You can remove the height from the css, or if you want to do this with jQuery you can use in something like this:

$('.synopsis').css('height','auto');
Sign up to request clarification or add additional context in comments.

Comments

0

If i've understood you correctly, then a simple way to find the text that's overflowed would be to add a visible background colour and comment out the overflow:hidden on your synopsis class, something along the lines of:

.synopsis {
  background: #FF0000;
  height: 32px;
  line-height: 16px;
  /*overflow: hidden;*/
  width: 600px;
}

Here a JSFiddle with what I mean: http://jsfiddle.net/UeaBA/4/

Comments

0

I dont think there is any easy way to obtain that in any script. The only way I can think as of now is to get the height and width of each character present in that div. You have to do certain calculations on these metrics to derive which characters fall in the visible area. This would be the most complex to do.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.