Home > Web Front-end > CSS Tutorial > Why Doesn't My SVG Background Image Display in Firefox Pseudo-elements?

Why Doesn't My SVG Background Image Display in Firefox Pseudo-elements?

Barbara Streisand
Release: 2024-12-21 10:42:14
Original
214 people have browsed it

Why Doesn't My SVG Background Image Display in Firefox Pseudo-elements?

SVG Background Image Not Displaying in Firefox Pseudo Element

In CSS, you can specify a background image for a pseudo element using the background-image property. However, when using data images, as in the case of SVG images, Firefox does not correctly display the image.

Cause:

The root cause lies in the use of the hash character (#) in the data URL. In a URL, the hash character is reserved to indicate the start of a fragment identifier.

Solution:

To resolve this issue, encode the hash character in the data URL by converting it to #. Here's how to do it:

background-image: url('data:image/svg+xml;utf8,<svg version="1.1">
Copy after login

By encoding the hash character, you ensure that it is correctly interpreted as part of the data URL and not as an identifier within the element. This change should resolve the issue, and the SVG image should display correctly as a background in the pseudo element in Firefox.

The above is the detailed content of Why Doesn't My SVG Background Image Display in Firefox Pseudo-elements?. 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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template