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

Why Doesn't My SVG Data URL Background Image Display in Firefox?

Barbara Streisand
Release: 2024-12-25 21:07:11
Original
225 people have browsed it

Why Doesn't My SVG Data URL Background Image Display in Firefox?

SVG Data URL Background-Image Not Displaying in Firefox

When setting an SVG as a background-image using a data URL in a pseudo element, the image fails to appear in Firefox. This is because Firefox treats the '#' character in the URL as the beginning of a fragment identifier.

To resolve this issue, the data URL contents must be URL encoded. This involves converting any '#' characters to '#'. The modified CSS code below incorporates the URL encoding:

content: '';
position: absolute;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 12px;
background-image: url('data:image/svg+xml;utf8,%3Csvg version="1.1">
Copy after login

By URL encoding the data URL contents, Firefox correctly interprets the hash characters as part of the SVG data, allowing the image to be displayed as the background.

The above is the detailed content of Why Doesn't My SVG Data URL Background Image Display in Firefox?. 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