Grow your CSS skills. Land your dream job.

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

  • # January 17, 2013 at 8:34 am

    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!

    # January 17, 2013 at 9:11 am

    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

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".