HiveBrain v1.2.0
Get Started
← Back to all entries
snippetcssTip

CSS units Cheat Sheet

Submitted by: @import:30-seconds-of-code··
0
Viewed 0 times
unitscheatsheetcss

Problem


  • px: Absolute pixel value
  • rem: Relative to the font-size of the root element
  • em: Relative to the font-size of the element
  • %: Relative to the parent element
  • vw: Relative to the viewport's width, 1vw = 1% * viewport width

Solution


  • em: Relative to the font-size of the element
  • %: Relative to the parent element
  • vw: Relative to the viewport's width, 1vw = 1% * viewport width
  • vh: Relative to the viewport's height, 1vh = 1% * viewport height
  • vmin: Relative to the viewport's smaller dimension, 1vmin = min(1vh, 1vw)
  • vmax: Relative to the viewport's larger dimension, vmax = max(1vh, 1vw)

Context

From 30-seconds-of-code: units-cheatsheet

Revisions (0)

No revisions yet.