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 6893881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:42:48+00:00 2026-05-27T06:42:48+00:00

Thanks for looking into this. Basically, what I am trying to do is to

  • 0

Thanks for looking into this.
Basically, what I am trying to do is to get the height of a div (which is set to 100% in my style.css, so it should be resizable on any device hopefully) so that I could print numbers 1-whatever number.

So for example if the window is small it’d print out the numbers 1-45, if it’s a smartphone browser, then the numbers will scale down to 1-10.

at the moment that’s what it looks like:

<div id="line_numbers">
        <script type="text/javascript">
            var i=0;
            var div_height=(document.getElementById('line_numbers').offsetHeight)/ getElementsByTagName("p").style.fontSize();

             while (i < div_height) { //if i is less that the height
                i++; //then increase its number
                document.write("<p>" + i + "</p>"); //and print out the number and new line (<p>)
            }
        </script><!--end of iteration script-->
</div><!--end of line numbers-->

I understand the height var calculation is wrong but I hope you understand the logic: Got the height of the div and given that padding for every

(every printed number) is 5px and the height of the font of every number, I can divide the height by the font size+10px (upper and lower padding).
When I try to print out the div_height variable nothing happens and I am a bit confused.

Thank you for taking time, again.

blagie-bla

  • 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-05-27T06:42:49+00:00Added an answer on May 27, 2026 at 6:42 am

    It looks like you got what you came for, but here’s a heads-up to supplement the answers above: Consider using element.style.lineHeight instead of element.style.fontSize, as only the former multiplied by the number of lines will give you the actual height of the div, (or an accurate line-count given height \ line-height).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is basically an extension to this answer . I am trying to get
Thanks for looking, all helpful answers are voted up. This is my markup. I'm
Thanks for looking on this problem. I have a page that is totally valid
Thanks for looking at this question. I wanted to know how can I use
Evening all. I have the following code that I need looking into - basically
I have been looking into this for a while and can't figure it out.
Well, this is embarrassing. I want to get into Flex development but I'm having
THanks for looking into my post. I guess I have a probably a pretty
I set myself this rather simple sounding challenge but now I am stuck trying
Thanks for looking. All sincerely helpful answers are voted up. I use a password

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.