Measurements
In responsive design, you’re no longer confined to just the pixel. You can use a variety of different CSS units, functions and values to set the width and height of elements. Knowing when to use the right unit gives you control over the way elements resize as the viewport width changes. You can find these units of measure under Sizing options in the Inspector panel.
Px
The pixel is the most straightforward unit. Choosing px makes sure the element's size is always the same regardless of the screen size.
%
The % unit is a very useful fluid unit. When setting width in %, the size is determined by a percentage of the parent container’s width. Alternatively, if the height is set to % the size is taken from the parent container’s height.
Vw
Vw stands for viewport width. Viewport is the size of the browser in which the site is displayed. 1vw equals 1% of the viewport’s width. Setting the width of an element to 100vw will make sure it takes up the full width of the viewport.
Vh
Vh is short for viewport height. 1vh equals 1% of the viewport’s height. Setting the height of an element to 100vh ensures it always takes up the full height of the viewport.
Auto
When a property is set to Auto, its size is determined by other factors and results may vary in the context of what else is being used. For example, the height and width of a stretched image is always set to Auto, as it simply fills up the available space.
Min & Max
While using fluid units of measure you can add a minimum or maximum to the width and, or height of an element. For instance if you set an element’s width to 50% it will remain half the size of its parent. You can then set a min width of 400px, so the element never gets smaller than that.
None
If a property is set to None, it means there is no value set for it. None can only be applied to min and max properties.
Fr
Fr is a fractional unit used for sizing columns and rows in a grid. 1fr represents 1 fraction of the available space. Sizing with fr is only available in Edit Grid mode.
EXPLORE MORE TUTORIALS
Was this lesson helpful?
Thank you for your feedback!