Differences in EM size among browsers

Discussion in 'HTML & Website Design' started by KewL, Nov 5, 2014.

  1. #1
    Is there anyway to even them out?

    I never really noticed the differences till yesterday when I was trying to hide something with negative margins. When compared to Chrome, Firefox/IE renders my box 2-3 PX larger, and opera 2-3 PX smaller.

    My solution was to set an estimate of the negative margin, then calculate the actual height in JavaScript and reset it. The 2-3px flash on non-chrome browsers bugs me though, and I'd rather not used fixed measurements.

    Here's what I'm talking about... Open this is a browser other than chrome:
    http://sitechop.com/demos/css3-js-slide-toggle-menu/index.html

    Any better solutions?
     
    KewL, Nov 5, 2014 IP
  2. hdewantara

    hdewantara Well-Known Member

    Messages:
    538
    Likes Received:
    47
    Best Answers:
    25
    Trophy Points:
    155
    #2
    Apply transition rule to the .nav ul,
    and play with its height (from 0em to 15em something),
    ...perhaps?
     
    hdewantara, Nov 5, 2014 IP
  3. tristanperry

    tristanperry Well-Known Member

    Messages:
    313
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #3
    I didn't think there was a way of evening out EM values, nope. Since they're based off the user's chosen font size, hence you cannot guarantee that they'll be consistent across all OSes and browsers.
     
    tristanperry, Nov 5, 2014 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Because EM's are a dynamic multiplier you'll find that sometimes with negative margins they just don't work right, particularly on HEIGHT.

    This is because in adding things up Firefox rounds all fractions up for display but never actually throws away the fraction overall; IE rounds up but throws the fraction away, and everyone else truncates before rendering. It's a pain in the ass and why sometimes with things like negative margin heights you are FORCED to either find another way of doing things or resorting to inaccessible pixel measurements.

    THOUGH -- MOST of the time if you stick to multiples of 5% you'll be ok... just don't be surprised if zoom + a different default size screws with your layout.

    Of course for what you are doing, it's a shame CSS3 implementations are too ***tarded to scale to height:auto -- NOT that when doing what you are attempting I see any reason to even get JS involved -- but as a rule I hate that stupid inaccessible "let's make mobile harder to use in the name of making it easier to use" menu hiding crap... though to be fair MOST of what you have there I wouldn't have there like the HTML 5 bloat for nothing.

    No joke though, have you tried using :target or the more complex input[checkbox]:checked>sibling methods? Scripting? BAH!
     
    deathshadow, Nov 5, 2014 IP