SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: some math

  1. #1
    SitePoint Guru
    Join Date
    Sep 2008
    Location
    Dubai
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    some math

    Hi guys,

    I need you to do me a math, I think it's easy and tricky at the same time.

    I have a pair value of font size and line height, 13px-20px, where 13px is font size and 20px is line height.

    Condition, if font-size increases by 1, line-height will increase by 2. So 14px font-size will result 22px line height.

    Now, if given a font-size value, can you figure out the line height?

  2. #2
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    is 13 the base font size ALWAYS?
    Ryan B | My Blog | Twitter

  3. #3
    SitePoint Guru
    Join Date
    Sep 2008
    Location
    Dubai
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the font is 13px, the line height must be 20px.
    If the font is 14px, the line height must be 22px.
    If the font is 15px, the line height must be 24px.

    So I give you font of 200px can you get the line height?

  4. #4
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    ok i haven't done this in years, this sounds like homework... I almost have it
    Ryan B | My Blog | Twitter

  5. #5
    SitePoint Addict WebMachine's Avatar
    Join Date
    Jun 2007
    Location
    Ontario, Canada
    Posts
    392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try doubling the font size and subtracting 6. This works with the three examples you showed.

  6. #6
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,892
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by WebMachine View Post
    Try doubling the font size and subtracting 6. This works with the three examples you showed.
    It always works.

    The lineheight starts at 20, and for every fontsize > 13, 2 will be added, so we get:

    lineheight = 20 + (fontsize-13) * 2

    which is equivalent to:

    lineheight = 20 + 2*fontsize - 26

    and that is equal to:

    lineheight = 2*fontsize - 6

    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  7. #7
    SitePoint Guru
    Join Date
    Sep 2008
    Location
    Dubai
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Congrat Webmachine and ScallioXTX, with very concise explanation. Thanks Guys!


Bookmarks

Posting Permissions

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