Back to the Learning

Back to the Learning!

Laracasts is packed full with over 1,000 lessons just like this one.
Sign up to get full access or log in to your account and sit back.

Fixed to the Top

Episode 42 Run Time 11:15

In this episode, we'll learn how to fix an HTML element to the top of the page, based upon the current scroll position. This is a common feature in countless websites. We'll tackle the implementation in two steps. First, we'll get it to work in the simplest way possible. Then, we'll refactor toward a reusable component that can be applied anywhere.

Note: JavaScript is necessary to allow for this functionality across all browsers. However, if you have the means, you might instead use CSS to accomplish the same effect much more easily.

Publish Date: June 4, 2018