--- title: Lock an Element to the Browser Window with Fixed Positioning --- # Lock an Element to the Browser Window with Fixed Positioning --- ## Hints ### Hint 1 Use `position: fixed;`. ### Hint 2 Use the `left` and `top` properties. --- ## Solutions
Solution 1 (Click to Show/Hide) ```html

Welcome!

I shift up when the #navbar is fixed to the browser window.

``` #### Code Explanation * `#navbar{}` selects all the elements with the ID of `navbar`. * `position: fixed;` positions the element with respect to the viewport i.e. the output screen in this case. * `top: 0px;` and `right: 0px;` offsets the element by `0px` to the top and left respectively and it is placed in the top-left corner of the screen.