Home > other >  how to change background image color without changing background
how to change background image color without changing background

Time:10-07

have a chevron in white color. Based on titles I want to change the color to black. tried filter but it gets applied to both background and background-image. How can I change the chevron to black by applying some kind of filter only to background-image?

    background-color: #cdfdfd;
    text-align: left !important;
    background-position-x: right;
    background-image: url(chevron-right-v2.svg);
    background-repeat: no-repeat;
    border-radius: 0.7vw;
    transition: background-color 250ms;
    background-position-y: center;
    color: #282828;

image for reference

CodePudding user response:

I don't think so that you can apply filters to a background image itself. but there is a workaround for this.

use ":before" element and give it height and width of 100% and the background-image, now you can apply a filter to this.

CodePudding user response:

I don't know if this helps or not, but if you look at W3School background-image: url("chevron-right-v2.svg"), you have to put quotes in the url

https://www.w3schools.com/cssref/pr_background-image.asp

  •  Tags:  
  • css
  • Related