How to use background-position in CSS

Source: Internet
Author: User

A. Background-position:left top;

The upper-left corner of the background picture is aligned with the upper-left corner of the container (container), and the excess is hidden. Equal to the background-position:0,0, also equal to the background-position:0%,0%;

Two. Background-position:right Bottom;

The bottom right corner of the background picture is aligned with the lower right corner of the container (container), and the excess is hidden. equivalent to background-positon:100%,100%; Background-positon: The width of the container (container)-the width of the background picture, the height of the container (container)-the height of the background picture

Three. background-position:500px 15px;.

The background picture moves from the top left corner of the container (container) to the right 500px, moves down 15px, and the excess part is hidden.

Four. background-position:-500px-15px;

The background picture moves from the top left corner of the container (container) to the left 500px, moves upward 15px, the excess part hides.

Five. background-position:50% 50%;.

Equivalent to the width of the left:{container (container)-the width of the background picture is}*left percent, and the excess is hidden. Equivalent to the height of the right:{container (container)-the height of the background picture}*right percent, the excess part hidden.

Six. background-position:-50%-50%;.

Equivalent to the width of the left:-{{container (container)-the width of the background picture is}*left percentage (the percentage is positive)}, and the excess is hidden. is equivalent to the height of the right:-{{container (container)-the height of the background picture is}*right percentage (the percentage is positive)}, and the excess is hidden.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.