Answer the question
In order to leave comments, you need to log in
What is the difference in these two ways of writing styles?
Option 1:
style ={{background: `url(${props.item.img}) center center no-repeat`,}}
style ={{
backgroundImage: `url(${props.item.img})`,
backgroundPosition: 'center center',
backgroundRepeat: 'no-repeat',
}}
Answer the question
In order to leave comments, you need to log in
I suspect some garbage arrives in img, which cuts off the rest of the record. Otherwise, no difference. Well, except that background overwrites all other properties (even those that are not specified, i.e. if background-color was set, it will become the default, i.e. transparent).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question