www.webdeveloper.com
Results 1 to 2 of 2

Thread: Get Number of Lines

  1. #1
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,105

    Get Number of Lines

    I'm trying to get the number of lines in an h4 so I can align them across a row. Basically, I have a category page, and I want to middle align the product names.

    The idea is to determine how many lines each one fills, then add the appropriate class.

    I want it to be dynamic as possible, so I'd prefer not to set any variables in the javascript. I was hoping I could do something like this:

    Code:
    var height = $(this).height(); // returns 45
    var lineHeight = $(this).css('line-height'); // returns normal - ideally, if it were 3 lines, it'd return 15
    
    var numLines = height/numLines // returns 3
    Is there any way to get the number of lines? Or have line height return a pixel value?
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  2. #2
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,105
    Bump.
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles