treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Possible to "em" instead of "px" for this font-size animation

  • Here is the current code, using pixels. It animates just fine.

      fontSize: $('span.heart').css('fontSize') == '150px' ? '50px' : '150px'}, 500, animateHeart);
    

    I tried using ems like this. But the animation does not work.

      fontSize: $('span.heart').css('fontSize') == '2em' ? '1em' : '2em'}, 500, animateHeart);
    

    http://codepen.io/jessecfisher/pen/HcdiL

    Thanks!

  • Inspect the heartbeat element on Chrome and you will see the font is changing but only after 2 so it is changing like:

    2.02012414, 2.12412412 etc

    This might be where your problem lies