Loading Please Wait...

Logo Lynxsia IT Solutions

CSS Position

CSS Position

The CSS position property sets how an element is positioned in a document. The top, right, bottom, and left properties determine the final location of positioned elements.

  • Static
  • Relative
  • Fixed
  • Absolute
  • Sticky
Position Static

The element is positioned according to the normal flow of the document. The top, right, bottom, left, and z-index properties have no effect. This is the default value.

					 
        
          .position-static{
            position: static;
          }
        
      
Position Relative

The element is positioned according to the normal flow of the document.

Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. Other content will not be adjusted to fit into any gap left by the element.

					 
        
          .position-relative{
            position: relative;
            top: 50px;
            left: 50px;
          }
        
      
Position Fixed

The element is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled.

The element is removed from the normal document flow, and no space is created for the element in the page layout.

					 
        
          .position-fixed{
            position: fixed;
            bottom: 50px;
            right: 50px;
          }
        
      
Position Absolute

The element is positioned relative to the nearest positioned ancestor (body in case of no ancestor).

The element is removed from the normal document flow, and no space is created for the element in the page layout.

					 
        
          .position-absolute{
            position: absolute;
            top: 50px;
            right: 50px;
          }
        
      
Position Sticky

The element is positioned based on the user's scroll position.

A sticky element toggles between relative and fixed, depending on the scroll position. It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position fixed).

The element is positioned according to the normal flow of the document, and then offset relative to its nearest scrolling ancestor

					 
        
          .position-sticky{
            position: sticky;
            top: 50px;
          }
        
      
If both top and bottom were defined then top wins.
If both left and right were defined then left wins when the direction is ltr and right wins when the direction is rtl.

How you feel about this blog:

Share this blog on:

Report Us

If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com

Contact Us
Ads
Logo
Lynxsia IT Solutions

We are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..

Kotwali Road, Chhiptehri, Banda, 210001, UP, India

Copyright © 2022, Lynxsia IT Solutions, All rights reserved