Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Layout Basics Positioning Page Content How Absolute Positioning Works

William Keely
William Keely
7,295 Points

Positioning Context?

Why is the positioning context the viewport? Is it absolute referencing always in relation tot he viewport? This seems to glossed over.

1 Answer

Steven Parker
Steven Parker
216,000 Points

The viewport is the default positioning context.

You can create another positioning context just by setting a parent or ancestor element's position to "relative". Then the offsets of the absolutely positioned element will be based on the other element and not the viewport.

Here's a Treehouse blog post with some addition explanation and illustrations.

William Keely
William Keely
7,295 Points

Thank you. Also Guil explained this more in the next video, so I have a good grasp of it now