Skip to content

Wrong margin-top unit #2

Description

@johnnygerard

The margin-top property should not use px units.

When visiting your CSS generator at https://range-input-css.netlify.app/, we see this CSS declaration:

  margin-top: -4px; /* Centers thumb on the track */

When using rem units for the track or thumb heights, this margin will remain the same when a user selects a non-default font-size. The thumb won't be vertically centered.

So it seems that calc should be used for margin-top:

  margin-top: calc((var(--track-height) - var(--thumb-height)) / 2); /* Centers thumb on the track */

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions