S.M_Emamian
S.M_Emamian

Reputation: 17383

backgroundImage style not loaded - react js

I want to use backgroundImage style but not rendered:

style={{backgroundImage: `url(${slider.img})`}

slider is a object.

this is my whole div tag:

div className="row owl-item"  id="bestOffer" style={{backgroundImage: `url(${slider.img})`}}>

Upvotes: 0

Views: 35

Answers (1)

mpontus
mpontus

Reputation: 2193

You need to put URL string in quotes for CSS:

<div 
    className="row owl-item" 
    id="bestOffer" 
    style={{
        backgroundImage: `url("${slider.img}")`
    }}
>

Upvotes: 1

Related Questions