Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Em cascading issue

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #191438
    Hung The
    Participant

    I have one issue which is spinning my head right now. I got along with em’s more or less well so far but here i ran into a nasty one.

    I made a simplified markup example. I have the <a> inside the <h2>

    http://codepen.io/thehung1724/pen/KwgKKp

    Now I want to put <a> tag inside the <h2> but it will too big because em units are relative to their parent. Is there way to fix it? Thank everyone.

    #191439
    shaneisme
    Participant

    You could do this:

    http://codepen.io/drainpip/pen/jEMONE

    But me personally I don’t mess with base-level elements and keep them at 1em always. Base-level elements like, p, li, a, etc…

    #191445
    Hung The
    Participant

    Hi,

    Thank you, now I can fix my issue by adding class to <h2> :D

    #191458
    Chris House
    Participant

    The obvious solution to this problem is to use rems instead of ems. Rems are based on the HTML element instead of the parent, so they don’t compound. Browser support isn’t perfect but there’s a good polyfill: https://github.com/chuckcarpenter/REM-unit-polyfill

    #191467
    Hung The
    Participant

    Hi,

    Ems also better expect cascading :)

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.