Fixed Positioning with CSS

CSSWeb DevelopmentFront End Technology

Fixed positioning allows you to fix the position of an element to a particular spot on the page, regardless of scrolling. Specified coordinates will be relative to the browser window.

You can use two values top and left along with the position property to move an HTML element anywhere in the HTML document.

  •  Move Left - Use a negative value for left.
  •  Move Right - Use a positive value for left
  •  Move Up - Use a negative value for top.
  •  Move Down - Use a positive value for top.

Example

You can try to run the following code to implement fixed positioning

 <html>
    <head>
    </head>
    <body>
       <div style = "position:fixed; left:80px; top:20px; background-color:blue;color:white;">
          This div has fixed positioning.
       </div>
    </body>
</html>
raja
Published on 18-Apr-2018 07:05:46
Advertisements