0

I have an image with a slight black linear gradient over it to improve readablitiy

.hero-image {
  background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("./images/slideshow/2.jpg");

However I am using a slideshow that only accepts divs with inline backgroundImage properties

<div
          className="slideshow-image"
          style={{ backgroundImage: `url(${slideshow2})`, repeat: "no-repeat" }}
        >

The trouble is I cannot add the linear gradient that the image had before with inline styling.

//attempt 1
const backgroundStyle = {
    backgroundImage: `url(${slideshow1})`,
    linearGradient: "(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))",
  };
// attempt 2 
style={{
            linearGradient: "(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))",
            backgroundImage: `url(${slideshow1})`,
            repeat: "no-repeat",
          }}

//attempt 3 
.slideshow-image {
 
  background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5));

Neither of these display anything over the image. What can I try next to accomplish this?

halfer
  • 19,824
  • 17
  • 99
  • 186
imstupidpleasehelp
  • 1,618
  • 2
  • 16
  • 36

1 Answers1

0

You can also override an inline CSS style using !important in your CSS.

Your CSS will become

.slideshow-image{
    background-repeat: no-repeat !important;
}

and your markup could be changed slightly

<div
          className="slideshow-image"
          style={{ backgroundImage: `url(${slideshow2})`}}
        >
Lamin Barrow
  • 839
  • 10
  • 16