Using SVGs as Pseudo-Element Content
The CSS content property allows for various types of content to be inserted before or after an element using pseudo-elements such as ::before and ::after. However, there have been restrictions on what content can be included.
Can SVGs be Used as Pseudo-Element Content?
Yes, it is now possible to use SVGs as content for pseudo-elements.
How to Use SVGs as Pseudo-Element Content
There are two methods to insert SVGs as pseudo-element content:
#test::before { content: url(path/to/your.svg); /* ... other styles */ }
#test::before { content: url("data:image/svg xml,
Example HTML:
Conclusion:
Using SVGs as pseudo-element content provides flexibility and allows for more visually appealing elements by incorporating vector graphics.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3