1. Definition and usage
The background-position property sets the starting position of the background image.
This attribute sets the position of the original background image (defined by background-image ). If the background image is to be repeated, it will start from this point.
Tip: You need to set the background-attachment property to "fixed" to ensure that this property works properly in Firefox and Opera.
0% 0% |
no |
CSS1 |
object.style.backgroundPosition="center" |
2. Possible values
|
Default: 0% 0%. | ||||||
x% y% | The first value is the horizontal position and the second value is the vertical position. The upper left corner is 0% 0%. The lower right corner is 100% 100%. If you specify only one value, the other value will be 50%.
| ||||||
xpos ypos | The first value is the horizontal position and the second value is the vertical position. The upper left corner is 0 0. Units are pixels (0px 0px) or any other CSS unit. If you specify only one value, the other value will be 50%. You can mix % and position values.
|
3. Example operation:
html css code:
Rendering effect:
1. When background-position:-110px -70px;
Rendering:
That is, the image is shifted 70px up and 110px to the left;
2. When background-position: 10px 10px;
Effect picture:
That is, move 10px to the right and 10px down;
3.background-position:100% 100%;
Rendering:
The image is in the lower right corner of the container element, which has the same effect as background-position:right bottom;.
Equivalent to x: {width of container (container)?width of background image}*x percentage, the excess part is hidden. That is, 50px to the right
is equivalent to y: {height of container (container)? height of background image}*y percentage, and the excess part is hidden. That is, 185px downward;
4.background-position:50% 50%;
The picture is centered horizontally and vertically. It has the same effect as background-position:center center;.
Equivalent to x: {width of container (container)?width of background image}*x percentage, the excess part is hidden.
Equivalent to y: {height of container (container)? height of background image}*y percentage, the excess part is hidden.
5.background-position:-50% -50%;
Equivalent to x: -{container (container) The width? The width of the background image}*x percentage, and the excess part is hidden. That is, moved 25px to the left;
is equivalent to y: - {height of container (container)? height of background image}*y percentage, and the excess part is hidden. That is, moved up 92.5px;
6.background-position:-100% -100%;
Rendering:
Equivalent to x: -{width of container (container)?width of background image}*x percentage, the excess part is hidden. That is, moved 50px to the left;
is equivalent to y: - {height of container (container)? height of background image}*y percentage, and the excess part is hidden. That is, it has moved up 185px;
Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver Mac version
Visual web development tools