Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7998595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:15:11+00:00 2026-06-04T15:15:11+00:00

in a long wordwrap element, is there any way to detect the left-top-most visible

  • 0

in a long wordwrap element, is there any way to detect the left-top-most visible word?

using span around each word or bunch of words is not really a good option as the text will be too long and dynamically loaded to be a good performance, but i may consider this is nothing else appears.

sample code (play with it http://jsfiddle.net/8utcp/2/ ):

<style> #test { height: 100px; width: 150px; overflow: auto; } </style>

<div id=test> with lots of text </div>

<script> $("#test").scrollTop(50); // simulate user scroll </script>

Now you have this in the test div:

scrolled text with word wrap

How do I figure out that the First visible word is “Adpiscing”?

answers can use any framework. be based around javascript or css. even solutions that do not work on all browsers are welcome as they can be a good starting point. I simply can’t find anything about this problem.

More clarification.
If I have a long text, and i open it in the browser and scroll down, and later i open it in another device, with different screen size, or even in the same browser, but with 10x more zoom. Which property/logic would ensure that the first visible word matches all the time.<

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:15:13+00:00Added an answer on June 4, 2026 at 3:15 pm

    the short answer is, no, you can’t get positions of words. the long answer is, you can do what you want to do but it’s hacky.

    what I can think of is this:

    • split based upon whitespace
    • walk the word tokens and inject a span element with, say–position absolute before and after the word, you can even st the innerHTML to orig wordsArray.join(" <span></span>") so your spaces/words become measurable or you can wrap every word in a span instead.
    • you can get the offsets of the spans from parent now, giving you rough coords for each word
    • work out – based upon scroll – which one is likely the first visible.
    • get rid of the spans.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to word wrap long string to 100 characters using XQuery. In other
Imagine I have a long, multi-word line of text in a DIV: Hello there,
Long time ago I made a socket based server application using the principle of
Long question Is it possible to add a DOM element only if it does
Possible Duplicate: wordwrap a very long string My code <div style=width:40px;>adfdddddddddddddddddddd</div> This code should
I have one long word... p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx+wnDhlr7GqHiH6lAaPPuN5F7RjUrtvGyxxZkClJsLaTDeqg/FuJXU7RYdPQ2Ka++tfw0Z9+SRKatLUQQeCqLK8z1/V4p7BaJKPkegMzXgWGnFVmz1tdLFiYUGq0MvVgqWiepcTFmwgSd9g1pGRiCSDHJUDwcc+NidiW4/ixw4QIDAQAB ...that I am trying to fit in a
I have $ad_text=wordwrap(nl2br($_POST['annonsera_text']), 45, '<br />\n'); Any idea why the above does display in
The content text in 1st td of table is very long, there is no
I'm trying to create a word-wrap in JavaScript using CSS, and the condition is:
I have <span class=text>11-12.SL.1 Some long text</span> where text has the following styles applied:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.