0

I'm using react. I've added a no-repeat style to backgroundImage, but the image doesn't show up.
when I remove the no-repeat, the image shows up.

    <div
      style={{
        position: 'relative',
        width: '580px',
        height: '460px',
        marginRight: '300px',
        marginBottom: '20px',
        marginLeft: '80px',
        backgroundImage: `url(${url}) no-repeat 50% 50%`,
      }}
    >
ryuma
  • 109
  • 1
  • 9

1 Answers1

2

The css background-image does not support repeat/no-repeat. You should use the background-repeat property.

backgroundRepeat: "no-repeat"

You could also use the css background shorthand to define multiple background style properties (in any order).

background: "no-repeat center url(./lolcat.png)"
Håken Lid
  • 22,318
  • 9
  • 52
  • 67