TO ALL LESSONS

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 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.

TRY IT YOURSELF

Exercise on measurements.

​Open Academy X from desktop to complete this exercise.

01

Try measurements in px. The size of the image is set in pixels so its size remains fixed at every breakpoint. Use the drag handles to resize the canvas and move between breakpoints.

02

Change to %. Select the image, open the Inspector panel and change the image width to 70%. Notice the sizing is now set to Fluid. Use the drag handles to see how its size changes across viewport sizes.

03

Set height as Auto. Change the image height to Auto. Notice that the Scale proportionally checkbox is checked. This means that the proportions of the image’s height and width will always be maintained. Use the drag handles to see it in action.

04

​Try min and max width. Set the Min W as 280px and the Max W as 800px. Now the image width will stay 70% of its parent so long as that׳s within 280-800px.

05

Set to 100vw. Now set the Min W and Max W to None to cancel the width limits. Change the image width to 100vw. This means that the image width will always be 100% of the viewport width. Use the drag handles to try it.

06

Set to 100vh. Now change the image height to 100vh. Click Preview and use the bottom and side handles to resize the viewport. You’ll see how the image always covers the entire width and height of the viewport.

NEXT: PARENTING

​​​PREVIOUS: BREAKPOINTS PART 2

LESSON 13

Measurements.

In responsive design, you’re no longer confined to just the pixel. You can use a variety of different CSS units of measure, 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.