admin管理员组

文章数量:1405501

I've been trying to place a block of rendered jsx to the right side of the first block for the past 2 hours. I can't seem to get it right. I tried using marginTop, marginLeft , etc., but those didn't work. I looked it up, and found that I could substitute with backgroundPosition. It hasn't worked though. Here's my current line: <div style={{backgroundPosition: -400 -100}}>

I've been trying to place a block of rendered jsx to the right side of the first block for the past 2 hours. I can't seem to get it right. I tried using marginTop, marginLeft , etc., but those didn't work. I looked it up, and found that I could substitute with backgroundPosition. It hasn't worked though. Here's my current line: <div style={{backgroundPosition: -400 -100}}>

Share Improve this question asked Oct 23, 2018 at 3:16 DanDan 1591 gold badge7 silver badges20 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

You need to escape the values to strings.

eg:

 <div style={{backgroundPosition: '-400px -100px'}}>

The object you are passing to the style attribute should be a plain javascript object - and needs to be valid as one.

本文标签: javascriptBackground Position inline style with ReactStack Overflow