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
Release: 2024-12-01 21:31:13
Original
209 people have browsed it

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;
Copy after login

For example:

background-position: right 30px center;
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template