How to make the picture move on top in css năm 2024

The background-position CSS property sets the initial position for each background image. The position is relative to the position layer set by background-origin.

/* Keyword values */
background-position: top;
background-position: bottom;
background-position: left;
background-position: right;
background-position: center;
/*  values */
background-position: 25% 75%;
/*  values */
background-position: 0 0;
background-position: 1cm 2cm;
background-position: 10ch 8em;
/* Multiple images */
background-position:
  0 0,
  center;
/* Edge offsets values */
background-position: bottom 10px right 20px;
background-position: right 3em bottom 10px;
background-position: bottom 10px right;
background-position: top right 10px;
/* Global values */
background-position: inherit;
background-position: initial;
background-position: revert;
background-position: revert-layer;
background-position: unset;

The background-position property is specified as one or more

(container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value)

0 values, separated by commas.

A

(container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value)

0. A position defines an x/y coordinate, to place an item relative to the edges of an element's box. It can be defined using one to four values. If two non-keyword values are used, the first value represents the horizontal position and the second represents the vertical position. If only one value is specified, the second value is assumed to be

(container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value)

3. If three or four values are used, the length-percentage values are offsets for the preceding keyword value(s).

1-value syntax: The value may be:

  • The keyword value (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 3, which centers the image.
  • One of the keyword values (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 5, (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 6, (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 7, or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 8. This specifies an edge against which to place the item. The other dimension is then set to 50%, so the item is placed in the middle of the edge specified.
  • A (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 9 or 100px - 300px = -200px (container & image difference) 0. This specifies the X coordinate relative to the left edge, with the Y coordinate set to 50%.

2-value syntax: One value defines X and the other defines Y. Each value may be:

  • One of the keyword values (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 5, (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 6, (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 7, or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 8. If (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 6 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 8 is given, then this defines X and the other given value defines Y. If (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 5 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 7 is given, then this defines Y and the other value defines X.
  • A (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 9 or 100px - 300px = -200px (container & image difference) 0. If the other value is (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 6 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 8, then this value defines Y, relative to the top edge. If the other value is (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 5 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 7, then this value defines X, relative to the left edge. If both values are (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 9 or 100px - 300px = -200px (container & image difference) 0 values, then the first defines X and the second Y.
  • Note that: If one value is (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 5 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 7, then the other value may not be (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 5 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 7. If one value is (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 6 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 8, then the other value may not be (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 6 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value)

    8. This means, e.g., that background-position = [#](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    hash%5Fmark)

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

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

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

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

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

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

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

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

    single%5Fbar)

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

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

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

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

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

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

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

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

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

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

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

    single%5Fbar)

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

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

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

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

    single%5Fbar) right []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

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

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

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

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

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

    single%5Fbar) bottom []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

    brackets)

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

    single%5Fbar)

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

    hash%5Fmark)

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

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

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

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

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

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

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

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

    single%5Fbar)

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

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

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

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

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

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

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

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

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

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

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

    single%5Fbar)

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

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

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

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

    single%5Fbar) right []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

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

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

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

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

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

    single%5Fbar) bottom []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

    brackets)

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

    single%5Fbar)

    6 are not valid.
  • Order: When pairing keywords, placement is not important as the browser can reorder it; the values

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

    hash%5Fmark)

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

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

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

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

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

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

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

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

    single%5Fbar)

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

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

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

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

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

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

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

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

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

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

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

    single%5Fbar)

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

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

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

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

    single%5Fbar) right []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

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

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

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

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

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

    single%5Fbar) bottom []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

    brackets)

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

    single%5Fbar)

    7 and background-position = [#](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

    hash%5Fmark)

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

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

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

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

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

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

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

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

    single%5Fbar)

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

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

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

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

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

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

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

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

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

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

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

    single%5Fbar)

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

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

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

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

    single%5Fbar) right []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

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

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

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

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

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

    single%5Fbar) bottom []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

    brackets)

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

    single%5Fbar)

    8 will yield the same result. When pairing (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value)

    9 or 100px - 300px = -200px (container & image difference) 0 with a keyword, the placement is important: the value defining X should come first followed by Y, so for example the value

    Example One
    Example Two
    Example Three

    1 is valid while

    Example One
    Example Two
    Example Three

    2 is invalid. The values

    Example One
    Example Two
    Example Three

    3 and

    Example One
    Example Two
    Example Three

    4 are valid as X and Y values are clearly defined and the placement is correct.
  • The default value is

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

    hash%5Fmark)

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

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

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

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

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

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

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

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

    single%5Fbar)

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

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

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

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

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

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

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

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

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

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

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

    single%5Fbar)

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

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

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

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

    single%5Fbar) right []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

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

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

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

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

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

    single%5Fbar) bottom []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

    brackets)

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

    single%5Fbar)

    8 or

    Example One
    Example Two
    Example Three

    6.

3-value syntax: Two values are keyword values, and the third is the offset for the preceding value:

  • The first value is one of the keyword values (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 5, (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 6, (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 7, (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 8, or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 3. If (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 6 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 8 are given here, then this defines X. If (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 5 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 7 are given, then this defines Y and the other keyword value defines X.
  • The (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 9 or 100px - 300px = -200px (container & image difference) 0 value, if it is the second value, is the offset for the first value. If it is the third value, it is the offset for the second value.
  • The single length or percentage value is an offset for the keyword value that precedes it. The combination of one keyword with two (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 9 or 100px - 300px = -200px (container & image difference) 0 values is not valid.

4-value syntax: The first and third values are keyword values defining X and Y. The second and fourth values are offsets for the preceding X and Y keyword values:

  • The first and third values are equal to one of the keyword values (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 5, (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 6, (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 7, or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 8. If (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 6 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 8 is given for the first value, then this defines X and the other value defines Y. If (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 5 or (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 7 is given for the first value, then this defines Y and the other keyword value defines X.
  • The second and fourth values are (container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value) 9 or 100px - 300px = -200px (container & image difference) 0 values. The second value is the offset for the first keyword. The fourth value is the offset for the second keyword.

The percentage offset of the given background image's position is relative to the container. A value of 0% means that the left (or top) edge of the background image is aligned with the corresponding left (or top) edge of the container, or the 0% mark of the image will be on the 0% mark of the container. A value of 100% means that the right (or bottom) edge of the background image is aligned with the right (or bottom) edge of the container, or the 100% mark of the image will be on the 100% mark of the container. Thus a value of 50% horizontally or vertically centers the background image as the 50% of the image will be at the 50% mark of the container. Similarly, `background-origin`0 means the spot on the image that is 25% from the left and 75% from the top will be placed at the spot of the container that is 25% from the container's left and 75% from the container's top.

Essentially what happens is the background image dimension is subtracted from the corresponding container dimension, and then a percentage of the resulting value is used as the direct offset from the left (or top) edge.

(container width - image width) (position x%) = (x offset value) (container height - image height) (position y%) = (y offset value)

Using the X axis for an example, let's say we have an image that is 300px wide and we are using it in a container that is 100px wide, with `background-origin`1 set to auto:

100px - 300px = -200px (container & image difference)

So that with position percentages of -25%, 0%, 50%, 100%, 125%, we get these image-to-container edge offset values:

-200px -25% = 50px -200px 0% = 0px -200px 50% = -100px -200px 100% = -200px -200px * 125% = -250px

So with these resultant values for our example, the left edge of the image is offset from the left edge of the container by:

  • + 50px (putting the left image edge in the center of the 100-pixel-wide container)
  • 0px (left image edge coincident with the left container edge)
  • -100px (left image edge 100px to the left of the container, in this example that means the middle 100px image area is centered in the container)
  • -200px (left image edge 200px to the left of the container, in this example that means the right image edge is coincident with the right container edge)
  • -250px (left image edge 250px to the left of the container, in this example that puts the right edge of the 300px-wide image in the center of the container)

It's worth mentioning that if your `background-origin`1 is equal to the container size for a given axis, then a percentage position for that axis will have no effect because the "container-image difference" will be zero. You will need to offset using absolute values.

Initial value

Example One
Example Two
Example Three

6Applies toall elements. It also applies to `background-origin`4 and `background-origin`5.InheritednoPercentagesrefer to the size of the background positioning area minus size of background image; size refers to the width for horizontal offsets and to the height for vertical offsetsComputed valueas each of the properties of the shorthand:

  • `background-origin`6: A list, each item consisting of: an offset given as a combination of an absolute length and a percentage, plus an origin keyword
  • `background-origin`7: A list, each item consisting of: an offset given as a combination of an absolute length and a percentage, plus an origin keyword Animation typea repeatable list

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

hash%5Fmark)

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

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

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

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

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

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

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

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

single%5Fbar)

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

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

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

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

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

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

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

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

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

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

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

single%5Fbar)

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

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

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

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

single%5Fbar) right []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

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

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

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

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

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

single%5Fbar) bottom []](https://developer.mozilla.org/en-US/docs/Web/CSS/Value%5Fdefinition%5Fsyntax

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

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

brackets)

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

single%5Fbar)

Each of these three examples uses the `background-origin`8 property to create a yellow, rectangular element containing a star image. In each example, the star is in a different position. The third example illustrates how to specify positions for two different background images within one element.

How do you shift the position of an image in CSS?

The image position in CSS can be changed by using CSS properties like object-position property and float property. Object-position property is used to align the position with respect to the x,y coordinates of the image within its container.

How to position images in CSS?

To change the position of an image in CSS, you can use properties such as object-position and float. The object-position property aligns the position of the image within its container using x and y coordinates.

How do you move an item to the top in CSS?

The position Property Setting position: absolute on an element lets you use the CSS properties top , bottom , left , and right to move the element around the page to exactly where you want it. For example, setting top: 1em move the element so its top is 1em from the top of the page.

How do I put an image on 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.