Home >Web Front-end >CSS Tutorial >How Can I Position a CSS Background Image a Fixed Distance from the Right Edge?

How Can I Position a CSS Background Image a Fixed Distance from the Right Edge?

DDD
DDDOriginal
2024-12-01 21:31:13298browse

How Can I Position a CSS Background Image a Fixed Distance from the Right Edge?

How to Place a CSS Background Image a Fixed Distance from the Right

In CSS, background-position values typically determine the pixel adjustment from the left and top edges. However, it is possible to position a background image a specific distance from the right side using the following syntax:

background-position: right [pixels] center;

For example:

background-position: right 30px center;

This code will position the background image 30 pixels from the right edge of the container, while aligning it vertically to the center.

Note that this solution works in most modern browsers, as per caniuse.com. For more information, refer to the W3C CSS3 Background Specification.

The above is the detailed content of How Can I Position a CSS Background Image a Fixed Distance from the Right Edge?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn