Categories
CSS

How to change the styles of an img src SVG with CSS?

Spread the love

To change the styles of an img src SVG with CSS, we set the mask property.

For instance, we write

<div class="logo"></div>

to add a div.

Then we write

.logo {
  background-color: red;
  -webkit-mask: url(logo.svg) no-repeat center;
  mask: url(logo.svg) no-repeat center;
}

to set the mask property to the svg URL to render the svg in the div.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *