From 2d07699cd6e7832df03c9c8f276cf8c22a9e2f59 Mon Sep 17 00:00:00 2001 From: The Coding Aviator <34807532+thecodingaviator@users.noreply.github.com> Date: Sat, 9 Mar 2019 19:33:18 +0530 Subject: [PATCH] Added solution to Lock an Element to the Browser Window with Fixed Positioning (#34318) * Update index.md * Update index.md --- .../index.md | 62 ++++++++++++++++++- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/guide/english/certifications/responsive-web-design/applied-visual-design/lock-an-element-to-the-browser-window-with-fixed-positioning/index.md b/guide/english/certifications/responsive-web-design/applied-visual-design/lock-an-element-to-the-browser-window-with-fixed-positioning/index.md index 973cc6bd21..cc608e13eb 100644 --- a/guide/english/certifications/responsive-web-design/applied-visual-design/lock-an-element-to-the-browser-window-with-fixed-positioning/index.md +++ b/guide/english/certifications/responsive-web-design/applied-visual-design/lock-an-element-to-the-browser-window-with-fixed-positioning/index.md @@ -1,10 +1,66 @@ --- title: Lock an Element to the Browser Window with Fixed Positioning --- + + Remember to use **`Read-Search-Ask`** if you get stuck. Try to pair program  and write your own code  + ## Lock an Element to the Browser Window with Fixed Positioning -This is a stub. Help our community expand it. +##  Hint: 1 -This quick style guide will help ensure your pull request gets accepted. +Use `position: fixed;`. - +> _try to solve the problem now_ + +##  Hint: 2 + +Use the `left` and `top` properties. + +> _try to solve the problem now_ + +## Spoiler Alert! + + + +**Solution ahead!** + +```html + +
+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.