1

Is there any way of recognizing text overflow with JS and show the overflowing text in an animated way? For example, moving the text to the left, like the spotify widget:

Spotify web Widget

2
  • Have a look at thsi.. dotdotdot.frebsite.nl if a plugin is fine with you Commented Jul 10, 2015 at 11:32
  • You can also try comparing the length of the String and if it is more than x (depends on your requirement) then replace the last three characters of the String by ... Commented Jul 10, 2015 at 11:36

1 Answer 1

1

You should be able to confirm a text requires scrolling if you use "scrollWidth > clientWidth " of the container - assuming it has overflow:hidden and you take margin, padding and borders into account. Look at element dimensions for a basic overview. To scroll the text you just have to give it a negative margin-left, or use a DIV with position:absolute inside a DIV with position:relative and give the inner one a negative left value (CSS).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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