Javatpoint Logo
Javatpoint Logo

CSS Position

The CSS position property is used to set position for an element. it is also used to place an element behind another and also useful for scripted animation effect.

You can position an element using the top, bottom, left and right properties. These properties can be used only after position property is set first. A position element's computed position property is relative, absolute, fixed or sticky.

Let's have a look at following CSS positioning:

  1. CSS Static Positioning
  2. CSS Fixed Positioning
  3. CSS Relative Positioning
  4. CSS Absolute Positioning

1) CSS Static Positioning

This is a by default position for HTML elements. It always positions an element according to the normal flow of the page. It is not affected by the top, bottom, left and right properties.


2) CSS Fixed Positioning

The fixed positioning property helps to put the text fixed on the browser. This fixed test is positioned relative to the browser window, and doesn't move even you scroll the window.

Test it Now

3) CSS Relative Positioning

The relative positioning property is used to set the element relative to its normal position.

Test it Now

4) CSS Absolute Positioning

The absolute positioning is used to position an element relative to the first parent element that has a position other than static. If no such element is found, the containing block is HTML.

With the absolute positioning, you can place an element anywhere on a page.

Test it Now

All CSS Position Properties

No. property description values
1) bottom It is used to set the bottom margin edge for a positioned box. auto, length, %, inherit
2) clip It is used to clip an absolutely positioned element. shape, auto, inherit
3) cursor It is used to specify the type of cursors to be displayed. url, auto, crosshair, default, pointer, move, e-resize, ne-resize, nw-resize, n-resize, se-resize, sw-resize, s-resize, w-resize, text, wait, help
4) left It sets a left margin edge for a positioned box. auto, length, %, inherit
5) overflow This property is used to define what happens if content overflow an element's box. auto, hidden, scroll, visible, inherit
6) position It is used to specify the type of positioning for an element. absolute, fixed, relative, static, inherit
7) right It is used to set a right margin edge for a positioned box. auto, length, %, inherit
8) top It is used to set a top margin edge for a positioned box. auto, length, %, inherit
9) z-index It is used to set stack order of an element. number, auto, inherit
Next TopicCSS Vertical Align




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA