Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-write -webkit-*** for CSS in JS React

I have these css

transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);

Now I want to move this to CSS in JS ReactJS style

const useStyles = makeStyles({
  transform: "translate(-50%, -50%)",
  -webkit-transform: "translate(-50%, -50%)",
  -ms-transform: "translate(-50%, -50%)"

However it can not be compiled

/src/views/LandingPage.js
  Line 85:5:  Parsing error: Unexpected token

  84 |     transform: "translate(-50%, -50%)",
> 85 |     -webkit-transform: "translate(-50%, -50%)",
     |     ^
  86 |     -ms-transform: "translate(-50%, -50%)"

How can I fix this??

like image 508
whitebear Avatar asked Oct 17 '25 12:10

whitebear


1 Answers

The Material UI makeStyles() accepts a normal JS object, so you can define the key using a string:

const useStyles = makeStyles({
myStyle:{
  "transform": "translate(-50%, -50%)",
  "-webkit-transform": "translate(-50%, -50%)",
  "-ms-transform": "translate(-50%, -50%)"
}
})
like image 178
OBN Avatar answered Oct 20 '25 02:10

OBN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!