How to use svg in background-image how to change color
Conclusion
After many tests, I discovered that background-image uses svg and changing the color cannot be done at all.
Analysis
When the svg image is used as background-image, the color setting needs to be inside the svg to take effect . Setting the color style in external CSS is invalid. This can actually be explained from the CSS selector. The CSS selector must select the DOM element, but the svg is made into a background image and is not introduced as an element, so it is not introduced externally. Can't set color.
Example
CSS:
i { display: inline-block; width: 100px; height: 100px; }.icon-del{ background-image: url(delete.svg); }.st0{fill:#EC665E;}.st1{fill:#FFFFFF;}
HTML :
<i class="icon-del"></i>
SVG:
<?xml version="1.0" encoding="utf-8"?><!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --><svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-691 693 16 16" style="enable-background:new -691 693 16 16;" xml:space="preserve"><title>删除群成员</title><desc>Created with Sketch.</desc><g id="Page-1"> <g id="群组名片成员_x28_管理员_x29_" transform="translate(-284.000000, -249.000000)"> <g id="Group-19"> <g id="Group-14" transform="translate(20.000000, 120.000000)"> <g id="群成员-copy-4" transform="translate(0.000000, 121.000000)"> <g id="删除群成员" transform="translate(264.000000, 8.000000)"> <g id="Group" transform="translate(2.000000, 2.000000)"> <g id="Oval-9"> <circle class="st0" cx="-685" cy="699" r="6"/> </g> <g id="Path-2"> <path class="st1" d="M-681,700h-8c-0.6,0-1-0.4-1-1s0.4-1,1-1h8c0.6,0,1,0.4,1,1S-680.4,700-681,700z"/> </g> </g> </g> </g> </g> </g> </g></g></svg>
The above is the detailed content of How to use svg in background-image how to change color. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



CSS gradient animation properties: transition and background-image In web design, animation effects can add vitality and appeal to the page. CSS provides many properties for creating animation effects, including the gradient animation properties transition and background-image. This article will introduce these two properties in detail and give specific code examples. transition attribute The transition attribute is used to implement elements in a

What are the employment prospects of clinical pharmacy at Harbin Medical University? Although the national employment situation is not optimistic, pharmaceutical graduates still have good employment prospects. Overall, the supply of pharmaceutical graduates is less than the demand. Pharmaceutical companies and pharmaceutical factories are the main channels for absorbing such graduates. The demand for talents in the pharmaceutical industry is also growing steadily. According to reports, in recent years, the supply-demand ratio for graduate students in majors such as pharmaceutical preparations and natural medicinal chemistry has even reached 1:10. Employment direction of clinical pharmacy major: After graduation, students majoring in clinical medicine can engage in medical treatment, prevention, medical research, etc. in medical and health units, medical research and other departments. Employment positions: Medical representative, pharmaceutical sales representative, sales representative, sales manager, regional sales manager, investment manager, product manager, product specialist, nurse

Recently, some friends reported how to download win10 image files. Because there are so many image files on the market, what should I do if I want to find a regular file to download? Today, the editor has brought you the link to download the image and the detailed solution steps. Let’s take a look at them together. win10 image quick download and installation tutorial download link >>> System Home Ghostwin101909 image 64-bit version v2019.11<<<>>>Win10 image 64-bit v2019.07<<<>>>Win10 image 32-bit v2019.07<< <1. Search through the Internet

How to clean the temp folder As we use the computer, temporary files (temp files) will gradually accumulate. These temporary files are generated when we use the computer, such as cache files when browsing the web, temporary files during software installation, etc. Failure to clean the temp folder for a long time may occupy a large amount of disk space and affect the speed of the computer. Therefore, cleaning the temp folder regularly is a necessary step to maintain computer performance. Below, we will introduce some simple ways to clean the temp folder. Method 1: Manually clean t

Detailed explanation of CSS image transition properties: transition and background-image Introduction: In modern web design, transition effects are an important technology to improve user interaction experience. Among them, image transition effects play an important role in beautifying web pages and improving user experience. This article will introduce in detail two commonly used image transition properties: transition and background-image, and provide specific code examples to help readers understand and apply them. 1. tran

How to reset Win10 system? Nowadays, many friends like to use computers with Win10 system. However, they will inevitably encounter some unsolvable problems when using computers. At this time, you can try to reset the system. So how should you do it? Let’s follow the editor to watch the tutorial on resetting the Win10 system. Users in need should not miss it. Tutorial on resetting the Win10 system 1. Click Windows and select Settings. 2. Click Update and Security. 3. Select Restore. 4. Click Start on the right to reset this computer. The above is the entire content of [How to reset Win10 system - Tutorial on resetting Win10 system]. More exciting tutorials are available on this site!

How to check win11 computer configuration? The win11 system is a very practical computer operating system version. This version provides users with rich functions, allowing users to have a better computer operating experience. So many friends who use computers are curious about their computers. Specific configuration, how to perform this operation in win11 system? Many friends don’t know how to operate in detail. The editor has compiled a tutorial on how to view the win11 computer configuration below. If you are interested, follow the editor and read on! Win11 computer configuration view tutorial 1. Click the windows icon on the taskbar below or press the "windows key" on the keyboard to open the start menu. 2. Find "Settings" or "sett" in the start menu.

How to solve the problem that the environment test fails when reinstalling the system and needs to be rewritten. The reason is: the mobile phone is poisoned. You can install anti-virus software such as Mobile Manager for anti-virus. 2. Many junk files are stored inside the mobile phone, causing the running memory of the mobile phone to be occupied. Just clear the phone cache to solve this problem. 3. The phone memory is occupied too much by saved software and files. It is no problem to delete unnecessary files and software frequently. As long as your hardware configuration meets the installation requirements, you can use the new one directly. Reinstall the system from the system disk! You can use a USB flash drive or hard disk to install, which is very fast. But the key is to use a system disk with good compatibility (supports installation in IDE, ACHI, and RAID modes), and it can be automatically and permanently activated, which has been verified. so
