Skip to content

Add a section dealing with length units: px vs rem vs em vs mod(n) #7

@mhairston

Description

@mhairston

(kelly) @mhairston are there variables I can use for the margins and padding as well? I couldn't find them I'm looking here: https://github.com/vhl/music/blob/master/app/assets/stylesheets/music/v1/library/base/settings/_units.scss

(mike)
The closest thing we have is the mod() function: mod(1) = 16px. The guideline is: stick to factors of two if you can (do I mean "factors"? I think I mean factors).

Good:
mod(1) mod(2) mod(4)
mod(1 / 2) mod(1 / 4) mod(3 / 2) mod(1.5)

Bad:
mod(5/8)
mod(0.333)

Pixels are not verboten. If you need margin-left: 17px because you're dealing with legacy or that's just how it has to be, just write it in pixels.

If you want it to be in proportion to the default text size, you can use rems. Right now, a mod happens to be equal to a rem, but if we decided to change the font size on the element, that would redefine rems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions