Img id hzdownscaled style position: absolute top: code năm 2024

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

The

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

1 CSS property sets how an element is positioned in a document. The

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

2,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

3,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

4, and

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

5 properties determine the final location of positioned elements.

position: static;
position: relative;
position: absolute;
position: fixed;
position: sticky;
/* Global values */
position: inherit;
position: initial;
position: revert;
position: revert-layer;
position: unset;

The element is positioned according to the Normal Flow of the document. The

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

2,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

3,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

4,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

5, and

One
Two
Three
Four

1 properties have no effect. This is the default value.

The element is positioned according to the normal flow of the document, and then offset relative to itself based on the values of

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

2,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

3,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

4, and

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

5. The offset does not affect the position of any other elements; thus, the space given for the element in the page layout is the same as if position were

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

6.

This value creates a new stacking context when the value of

One
Two
Three
Four

1 is not

One
Two
Three
Four

9. Its effect on

  • { box-sizing: border-box; } .box { display: inline-block; width: 100px; height: 100px; background: red; color: white; }
# two { position: relative; top: 20px; left: 20px; background: blue; }

0,

  • { box-sizing: border-box; } .box { display: inline-block; width: 100px; height: 100px; background: red; color: white; }
# two { position: relative; top: 20px; left: 20px; background: blue; }

1,

  • { box-sizing: border-box; } .box { display: inline-block; width: 100px; height: 100px; background: red; color: white; }
# two { position: relative; top: 20px; left: 20px; background: blue; }

2,

  • { box-sizing: border-box; } .box { display: inline-block; width: 100px; height: 100px; background: red; color: white; }
# two { position: relative; top: 20px; left: 20px; background: blue; }

3, and

  • { box-sizing: border-box; } .box { display: inline-block; width: 100px; height: 100px; background: red; color: white; }
# two { position: relative; top: 20px; left: 20px; background: blue; }

4 elements is undefined.

The element is removed from the normal document flow, and no space is created for the element in the page layout. The element is positioned relative to its closest positioned ancestor (if any) or to the initial . Its final position is determined by the values of

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

2,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

3,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

4, and

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

5.

This value creates a new stacking context when the value of

One
Two
Three
Four

1 is not

One
Two
Three
Four

9. The margins of absolutely positioned boxes do not collapse with other margins.

The element is removed from the normal document flow, and no space is created for the element in the page layout. The element is positioned relative to its initial , which is the viewport in the case of visual media. Its final position is determined by the values of

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

2,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

3,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

4, and

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

5.

This value always creates a new stacking context. In printed documents, the element is placed in the same position on every page.

The element is positioned according to the normal flow of the document, and then offset relative to its nearest scrolling ancestor and containing block (nearest block-level ancestor), including table-related elements, based on the values of

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

2,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

3,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

4, and

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

5. The offset does not affect the position of any other elements.

This value always creates a new stacking context. Note that a sticky element "sticks" to its nearest ancestor that has a "scrolling mechanism" (created when

  • { box-sizing: border-box; } body { width: 500px; margin: 0 auto; } p { background: aqua; border: 3px solid blue; padding: 10px; margin: 10px; } span { background: red; border: 1px solid black; } .positioned { position: absolute; background: yellow; top: 30px; left: 30px; }

2 is

  • { box-sizing: border-box; } body { width: 500px; margin: 0 auto; } p { background: aqua; border: 3px solid blue; padding: 10px; margin: 10px; } span { background: red; border: 1px solid black; } .positioned { position: absolute; background: yellow; top: 30px; left: 30px; }

3,

  • { box-sizing: border-box; } body { width: 500px; margin: 0 auto; } p { background: aqua; border: 3px solid blue; padding: 10px; margin: 10px; } span { background: red; border: 1px solid black; } .positioned { position: absolute; background: yellow; top: 30px; left: 30px; }

4,

One
Two
Three
Four

9, or

  • { box-sizing: border-box; } body { width: 500px; margin: 0 auto; } p { background: aqua; border: 3px solid blue; padding: 10px; margin: 10px; } span { background: red; border: 1px solid black; } .positioned { position: absolute; background: yellow; top: 30px; left: 30px; }

6), even if that ancestor isn't the nearest actually scrolling ancestor.

Note: At least one inset property (

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

2,

  • { box-sizing: border-box; } body { width: 500px; margin: 0 auto; } p { background: aqua; border: 3px solid blue; padding: 10px; margin: 10px; } span { background: red; border: 1px solid black; } .positioned { position: absolute; background: yellow; top: 30px; left: 30px; }

8,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

3,

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor eget pulvinar lobortis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ac dolor augue. Pellentesque mi mi, laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit. Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut arcu aliquam purus viverra dictum vel sit amet mi. Duis nisl mauris, aliquam sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem aliquam, congue porttitor tortor. Sed tempor nisl a lorem consequat, id maximus erat aliquet. Sed sagittis porta libero sed condimentum. Aliquam finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id ultrices ultrices, tempor et tellus.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor eget pulvinar lobortis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ac dolor augue. Pellentesque mi mi, laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit. Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut arcu aliquam purus viverra dictum vel sit amet mi. Duis nisl mauris, aliquam sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem aliquam, congue porttitor tortor. Sed tempor nisl a lorem consequat, id maximus erat aliquet. Sed sagittis porta libero sed condimentum. Aliquam finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id ultrices ultrices, tempor et tellus.

One

0, etc.) needs to be set to a non-

One
Two
Three
Four

9 value for the axis on which the element needs to be made sticky. If both

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor eget pulvinar lobortis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ac dolor augue. Pellentesque mi mi, laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit. Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut arcu aliquam purus viverra dictum vel sit amet mi. Duis nisl mauris, aliquam sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem aliquam, congue porttitor tortor. Sed tempor nisl a lorem consequat, id maximus erat aliquet. Sed sagittis porta libero sed condimentum. Aliquam finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id ultrices ultrices, tempor et tellus.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor eget pulvinar lobortis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ac dolor augue. Pellentesque mi mi, laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit. Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut arcu aliquam purus viverra dictum vel sit amet mi. Duis nisl mauris, aliquam sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem aliquam, congue porttitor tortor. Sed tempor nisl a lorem consequat, id maximus erat aliquet. Sed sagittis porta libero sed condimentum. Aliquam finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id ultrices ultrices, tempor et tellus.

One

2 properties for an axis are set to

One
Two
Three
Four

9, on that axis the

Absolute positioning

I am a basic block level element. My adjacent block level elements sit on new lines below me.

By default we span 100% of the width of our parent element, and we are as tall as our child content. Our total width and height is our content + padding + border width/height.

We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.

inline elements like this one and this one sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements wrap onto a new line if possible — like this one containing text, or just go on to a new line if not, much like this image will do:

Img id hzdownscaled style position: absolute top: code năm 2024

7 value will behave as

One
Two
Three
Four

2.

  • A positioned element is an element whose computed

    position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 1 value is either

    One
    Two
    Three
    Four

    2,

    `
  • { box-sizing: border-box; } .box { display: inline-block; width: 100px; height: 100px; background: red; color: white; }

two {

position: relative; top: 20px; left: 20px; background: blue; }

5,  

Absolute positioning

I am a basic block level element. My adjacent block level elements sit on new lines below me.

By default we span 100% of the width of our parent element, and we are as tall as our child content. Our total width and height is our content + padding + border width/height.

We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.

inline elements like this one and this one sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements wrap onto a new line if possible — like this one containing text, or just go on to a new line if not, much like this image will do:

Img id hzdownscaled style position: absolute top: code năm 2024

2, or  

Absolute positioning

I am a basic block level element. My adjacent block level elements sit on new lines below me.

By default we span 100% of the width of our parent element, and we are as tall as our child content. Our total width and height is our content + padding + border width/height.

We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.

inline elements like this one and this one sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements wrap onto a new line if possible — like this one containing text, or just go on to a new line if not, much like this image will do:

Img id hzdownscaled style position: absolute top: code năm 2024

7\. (In other words, it's anything except  
position =  
  static       [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax
# single%5Fbar)  
  relative     [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax
# single%5Fbar)  
  absolute     [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax
# single%5Fbar)  
  sticky       [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax
# single%5Fbar)  
  fixed        [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax
# single%5Fbar)  
    
 =  
  running( [](https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident) )  
6.)
  • A relatively positioned element is an element whose computed position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) = running( [](https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident) ) 1 value is
    One
    Two
    Three
    Four
    2\. The position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) = running( [](https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident) ) 2 and position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) = running( [](https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident) ) 4 properties specify the vertical offset from its normal position; the position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) = running( [](https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident) ) 5 and position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) = running( [](https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident) ) 3 properties specify the horizontal offset.
  • An absolutely positioned element is an element whose computed position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax # single%5Fbar) = running( [](https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident) ) 1 value is `
  • { box-sizing: border-box; } .box { display: inline-block; width: 100px; height: 100px; background: red; color: white; }
# two { position: relative; top: 20px; left: 20px; background: blue; }
5 or

Absolute positioning

I am a basic block level element. My adjacent block level elements sit on new lines below me.

By default we span 100% of the width of our parent element, and we are as tall as our child content. Our total width and height is our content + padding + border width/height.

We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.

inline elements like this one and this one sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements wrap onto a new line if possible — like this one containing text, or just go on to a new line if not, much like this image will do:

Img id hzdownscaled style position: absolute top: code năm 2024

2. The position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( ) 2, position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( ) 3, position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( ) 4, and position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( ) 5 properties specify offsets from the edges of the element's containing block. (The containing block is the ancestor relative to which the element is positioned.) If the element has margins, they are added to the offset. The element establishes a new block formatting context (BFC) for its contents.

  • A stickily positioned element is an element whose computed

    position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 1 value is

    Absolute positioning

    I am a basic block level element. My adjacent block level elements sit on new lines below me.

    By default we span 100% of the width of our parent element, and we are as tall as our child content. Our total width and height is our content + padding + border width/height.

    We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.

    inline elements like this one and this one sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements wrap onto a new line if possible — like this one containing text, or just go on to a new line if not, much like this image will do:

    Img id hzdownscaled style position: absolute top: code năm 2024

    7. It's treated as relatively positioned until its containing block crosses a specified threshold (such as setting position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 2 to value other than auto) within its flow root (or the container it scrolls within), at which point it is treated as "stuck" until meeting the opposite edge of its containing block.

Most of the time, absolutely positioned elements that have


# one {
  position: sticky;
  top: 10px;
}

8 and


# one {
  position: sticky;
  top: 10px;
}

9 set to

One
Two
Three
Four

9 are sized so as to fit their contents. However, non-replaced, absolutely positioned elements can be made to fill the available vertical space by specifying both

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

2 and

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

4 and leaving


# one {
  position: sticky;
  top: 10px;
}

8 unspecified (that is,

One
Two
Three
Four

9). They can likewise be made to fill the available horizontal space by specifying both

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

5 and

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

3 and leaving


# one {
  position: sticky;
  top: 10px;
}

9 as

One
Two
Three
Four

9.

Except for the case just described (of absolutely positioned elements filling the available space):

  • If both

    position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 2 and position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 4 are specified (technically, not

    One
    Two
    Three
    Four

    9), position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 2 wins.
  • If both

    position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 5 and position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 3 are specified, position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 5 wins when position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 06 is position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 07 (English, horizontal Japanese, etc.) and position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 3 wins when position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 06 is position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    single%5Fbar)

    = running( ) 10 (Persian, Arabic, Hebrew, etc.).

Ensure that elements positioned with an

  • { box-sizing: border-box; } .box { display: inline-block; width: 100px; height: 100px; background: red; color: white; }
# two { position: relative; top: 20px; left: 20px; background: blue; }

5 or

Absolute positioning

I am a basic block level element. My adjacent block level elements sit on new lines below me.

By default we span 100% of the width of our parent element, and we are as tall as our child content. Our total width and height is our content + padding + border width/height.

We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.

inline elements like this one and this one sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements wrap onto a new line if possible — like this one containing text, or just go on to a new line if not, much like this image will do:

Img id hzdownscaled style position: absolute top: code năm 2024

2 value do not obscure other content when the page is zoomed to increase text size.

  • Visual Presentation: Understanding SC 1.4.8 | Understanding WCAG 2.0

Scrolling elements containing

Absolute positioning

I am a basic block level element. My adjacent block level elements sit on new lines below me.

By default we span 100% of the width of our parent element, and we are as tall as our child content. Our total width and height is our content + padding + border width/height.

We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.

inline elements like this one and this one sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements wrap onto a new line if possible — like this one containing text, or just go on to a new line if not, much like this image will do:

Img id hzdownscaled style position: absolute top: code năm 2024

2 or

Absolute positioning

I am a basic block level element. My adjacent block level elements sit on new lines below me.

By default we span 100% of the width of our parent element, and we are as tall as our child content. Our total width and height is our content + padding + border width/height.

We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.

inline elements like this one and this one sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements wrap onto a new line if possible — like this one containing text, or just go on to a new line if not, much like this image will do:

Img id hzdownscaled style position: absolute top: code năm 2024

7 content can cause performance and accessibility issues. As a user scrolls, the browser must repaint the sticky or fixed content in a new location. Depending on the content needing to be repainted, the browser performance, and the device's processing speed, the browser may not be able to manage repaints at 60 fps, causing accessibility concerns for people with sensitivities and jank for everyone. One solution is to add

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

15 to the positioned elements to render the element in its own layer, improving repaint speed and therefore improving performance and accessibility.

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

Relatively positioned elements are offset a given amount from their normal position within the document, but without the offset affecting other elements. In the example below, note how the other elements are placed as if "Two" were taking up the space of its normal location.

HTML

One
Two
Three
Four

CSS

  • { box-sizing: border-box; } .box { display: inline-block; width: 100px; height: 100px; background: red; color: white; }
# two { position: relative; top: 20px; left: 20px; background: blue; }

Elements that are relatively positioned remain in the normal flow of the document. In contrast, an element that is absolutely positioned is taken out of the flow; thus, other elements are positioned as if it did not exist. The absolutely positioned element is positioned relative to its nearest positioned ancestor (i.e., the nearest ancestor that is not

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

6). If a positioned ancestor doesn't exist, it is positioned relative to the ICB (initial containing block — see also the ), which is the containing block of the document's root element.

HTML

Absolute positioning

I am a basic block level element. My adjacent block level elements sit on new lines below me.

By default we span 100% of the width of our parent element, and we are as tall as our child content. Our total width and height is our content + padding + border width/height.

We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.

inline elements like this one and this one sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements wrap onto a new line if possible — like this one containing text, or just go on to a new line if not, much like this image will do:

Img id hzdownscaled style position: absolute top: code năm 2024

CSS

  • { box-sizing: border-box; } body { width: 500px; margin: 0 auto; } p { background: aqua; border: 3px solid blue; padding: 10px; margin: 10px; } span { background: red; border: 1px solid black; } .positioned { position: absolute; background: yellow; top: 30px; left: 30px; }

Result

Fixed positioning is similar to absolute positioning, with the exception that the element's containing block is the initial containing block established by the viewport, unless any ancestor has

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

17,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

18, or

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

19 property set to something other than

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

20 (see ), which then causes that ancestor to take the place of the elements containing block. This can be used to create a "floating" element that stays in the same position regardless of scrolling. In the example below, box "One" is fixed at 80 pixels from the top of the page and 10 pixels from the left. Even after scrolling, it remains in the same place relative to the viewport. Also, when the

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

21 property is set to

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

17, a new containing block is established.

HTML

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor eget pulvinar lobortis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ac dolor augue. Pellentesque mi mi, laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit. Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut arcu aliquam purus viverra dictum vel sit amet mi. Duis nisl mauris, aliquam sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem aliquam, congue porttitor tortor. Sed tempor nisl a lorem consequat, id maximus erat aliquet. Sed sagittis porta libero sed condimentum. Aliquam finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id ultrices ultrices, tempor et tellus.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam congue tortor eget pulvinar lobortis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam ac dolor augue. Pellentesque mi mi, laoreet et dolor sit amet, ultrices varius risus. Nam vitae iaculis elit. Aliquam mollis interdum libero. Sed sodales placerat egestas. Vestibulum ut arcu aliquam purus viverra dictum vel sit amet mi. Duis nisl mauris, aliquam sit amet luctus eget, dapibus in enim. Sed velit augue, pretium a sem aliquam, congue porttitor tortor. Sed tempor nisl a lorem consequat, id maximus erat aliquet. Sed sagittis porta libero sed condimentum. Aliquam finibus lectus nec ante congue rutrum. Curabitur quam quam, accumsan id ultrices ultrices, tempor et tellus.

One

CSS

  • { box-sizing: border-box; } .box { width: 100px; height: 100px; background: red; color: white; }
# one { position: fixed; top: 80px; left: 10px; background: blue; } .outer { width: 500px; height: 300px; overflow: scroll; padding-left: 150px; }

Result

Sticky positioning can be thought of as a hybrid of relative and fixed positioning when its nearest scrolling ancestor is the viewport. A stickily positioned element is treated as relatively positioned until it crosses a specified threshold, at which point it is treated as fixed until it reaches the boundary of its parent. For example:


# one {
  position: sticky;
  top: 10px;
}

The above CSS rule would position the element with id one relatively until the viewport was scrolled such that the element would be less than 10 pixels from the top. Beyond that threshold, the element would be fixed to 10 pixels from the top.

A common use for sticky positioning is for the headings in an alphabetized list. The "B" heading will appear just below the items that begin with "A" until they are scrolled offscreen. Rather than sliding offscreen with the rest of the content, the "B" heading will then remain fixed to the top of the viewport until all the "B" items have scrolled offscreen, at which point it will be covered up by the "C" heading, and so on.

You must specify a threshold with at least one of

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

2,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

3,

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

4, or

position = static [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

relative [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

absolute [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

sticky [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

fixed [|](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

single%5Fbar)

= running( )

5 for sticky positioning to behave as expected. Otherwise, it will be indistinguishable from relative positioning.

How to position an img in HTML?

To arrange images and text in HTML, you can use CSS (Cascading Style Sheets). You can use the float property to position images and text side by side, or use the position property to place them in a specific location on the page.

How to align an image to the top right?

Align Image in HTML Using the Align Attribute.

The align attribute indicates how an image should be aligned concerning its container. To align the image, we use the align attribute. ... .

We Use the attribute value left to align the image to the left..

We use the attribute value right to align the image to the right..

How to move an image to top right in CSS?

To position a fixed element in the top right corner of a web page, you can use CSS. You can add the position: fixed property to the element you want to position and then use the top , right , bottom , and left properties to adjust its position.

How do I center an image with position absolute?

Centering using absolute position To center an element using absolute positioning, just follow these steps: Add left: 50% to the element that you want to center. You will notice that this aligns the left edge of the child element with the 50% line of the parent.