Lesson info

Lesson info

Explore this project

Want to dig into the project featured in this video and see how everything is put together? We've included the full project we used when making this lesson, and we've shared the link right under this very paragraph.

View and clone this projectDownload lesson assets
Clone this projectDownload project assets

Transcript

An element's Position can be set in a number of ways. This is really helpful when we're creating designs that require overlapping elements, or even elements that are persistently Positioned on the viewport, regardless of your scroll Position.

We'll talk about these four: Auto (or Static), Relative, Absolute, and Fixed. This is a quick crash course on these four.

Let's do Auto. This is what we generally refer to as the "normal document flow." (Elements stacking and wrapping like we'd expect in a Word document).

But for now, let's do Relative Positioning. Three images side-by-side. Three paragraphs underneath. The second image, with Relative Positioning we can move this left and right to partially overlap the other images. And what's cool about Relative Positioning is it doesn't interrupt or mess with the normal document flow. It leaves a seat warmer in its place. Its spot is held and moving it isn't messing with other content.

Let's do this with the paragraphs. Same thing with Relative Positioning here. We can overlap other content without affecting the normal document flow.

Let's do Absolute Positioning. Same setup as Relative here. But when we set this element to Absolute? It's completely removed from the document flow. Yanked out. In this case, the image's parent element has its Position set to Relative, which means our Absolutely-Positioned image is Positioned around that parent element.

And finally, let's cover Fixed. Fixed elements are Positioned around the viewport; not their parent element. That means we can scroll down the page and the Fixed elements stay Fixed — they stay where they are Relative to the viewport.

So, auto (or Static) Positioning respects the normal document flow. Relative Positioning lets us move our elements around without messing with the document flow. Absolute Position positions content around its parent element. And Fixed Position positions content Relative to the viewport, persistently holding something where it is regardless of scrolling.